@@ -36,22 +36,29 @@ func (op *opcode) Analyze(path string, withTrace bool) ([]*analyzer.Issue, error
3636 for _ , segment := range callGraph .Segments () {
3737 for _ , instruction := range segment .Instructions () {
3838 if ! op .isAllowedOpcode (instruction .OpcodeHex (), instruction .Funct ()) {
39- source , err := common .TraceAsmCaller (absPath , callGraph , segment .Label (), endCondition )
39+ source , err := common .TraceAsmCaller (
40+ absPath ,
41+ callGraph ,
42+ segment .Label (),
43+ common .ProgramEntrypoint (op .profile .GOARCH ),
44+ )
4045 if err != nil { // non-reachable portion ignored
4146 continue
4247 }
43- if common .ShouldIgnoreSource (source , op .profile .IgnoredFunctions ) {
44- continue
45- }
4648 if ! withTrace {
4749 source .CallStack = nil
4850 }
49- issues = append (issues , & analyzer.Issue {
51+
52+ issue := & analyzer.Issue {
5053 Severity : analyzer .IssueSeverityCritical ,
5154 CallStack : source ,
52- Message : fmt .Sprintf ("Incompatible Opcode Detected: Opcode: %s, Funct: %s" ,
55+ Message : fmt .Sprintf ("Potential Incompatible Opcode Detected: Opcode: %s, Funct: %s" ,
5356 instruction .OpcodeHex (), instruction .Funct ()),
54- })
57+ }
58+ if common .ShouldIgnoreSource (source , op .profile .IgnoredFunctions ) {
59+ issue .Severity = analyzer .IssueSeverityWarning
60+ }
61+ issues = append (issues , issue )
5562 }
5663 }
5764 }
@@ -87,7 +94,7 @@ func (op *opcode) TraceStack(path string, function string) (*analyzer.CallStack,
8794 if err != nil {
8895 return nil , err
8996 }
90- return common .TraceAsmCaller (absPath , graph , function , endCondition )
97+ return common .TraceAsmCaller (absPath , graph , function , common . ProgramEntrypoint ( op . profile . GOARCH ) )
9198}
9299func (op * opcode ) isAllowedOpcode (opcode , funct string ) bool {
93100 return slices .ContainsFunc (op .profile .AllowedOpcodes , func (instr profile.OpcodeInstruction ) bool {
@@ -102,10 +109,3 @@ func (op *opcode) isAllowedOpcode(opcode, funct string) bool {
102109 })
103110 })
104111}
105-
106- func endCondition (function string ) bool {
107- return function == "runtime.rt0_go" || // start point of a go program
108- function == "main.main" || // main
109- strings .Contains (function , ".init." ) || // all init functions
110- strings .HasSuffix (function , ".init" ) // vars
111- }
0 commit comments