File tree Expand file tree Collapse file tree
binary/ql/lib/semmle/code/binary/ast/ir Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -321,6 +321,12 @@ private module FinalInstruction {
321321 }
322322 }
323323
324+ class FieldAddressInstruction extends Instruction instanceof Instruction:: FieldAddressInstruction {
325+ UnaryOperand getBaseOperand ( ) { result = super .getBaseOperand ( ) }
326+
327+ string getFieldName ( ) { result = super .getFieldName ( ) }
328+ }
329+
324330 class SubInstruction extends BinaryInstruction instanceof Instruction:: SubInstruction { }
325331
326332 class AddInstruction extends BinaryInstruction instanceof Instruction:: AddInstruction { }
Original file line number Diff line number Diff line change @@ -179,6 +179,16 @@ class ExternalRefInstruction extends Instruction {
179179 final override string getImmediateValue ( ) { result = this .getExternalName ( ) }
180180}
181181
182+ class FieldAddressInstruction extends Instruction {
183+ override Opcode:: FieldAddress opcode ;
184+
185+ UnaryOperand getBaseOperand ( ) { result = this .getAnOperand ( ) }
186+
187+ string getFieldName ( ) { result = te .getFieldName ( tag ) }
188+
189+ final override string getImmediateValue ( ) { result = this .getFieldName ( ) }
190+ }
191+
182192class FunEntryInstruction extends Instruction {
183193 override Opcode:: FunEntry opcode ;
184194}
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ private import codeql.controlflow.SuccessorType
44private import semmle.code.binary.ast.Location
55
66signature module InstructionSig {
7-
87 class Type {
98 Function getAFunction ( ) ;
109
@@ -267,6 +266,12 @@ signature module InstructionSig {
267266 string getStringValue ( ) ;
268267 }
269268
269+ class FieldAddressInstruction extends Instruction {
270+ UnaryOperand getBaseOperand ( ) ;
271+
272+ string getFieldName ( ) ;
273+ }
274+
270275 class ControlFlowNode {
271276 Instruction asInstruction ( ) ;
272277
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ private newtype TOpcode =
2424 TNop ( ) or
2525 TNot ( ) or
2626 TInit ( ) or
27+ TFieldAddress ( ) or
2728 // TODO: Ideally, this should either be removed when we handle unresolved CIL calls better.
2829 TExternalRef ( ) or
2930 TFunEntry ( )
@@ -144,6 +145,10 @@ class Init extends Opcode, TInit {
144145 override string toString ( ) { result = "Init" }
145146}
146147
148+ class FieldAddress extends Opcode , TFieldAddress {
149+ override string toString ( ) { result = "FieldAddress" }
150+ }
151+
147152newtype ConditionKind =
148153 EQ ( ) or
149154 NE ( ) or
Original file line number Diff line number Diff line change @@ -732,6 +732,21 @@ module Transform<InstructionSig Input> {
732732 }
733733 }
734734
735+ class FieldAddressInstruction extends Instruction {
736+ FieldAddressInstruction ( ) { this .getOpcode ( ) instanceof Opcode:: FieldAddress }
737+
738+ UnaryOperand getBaseOperand ( ) { result = this .getAnOperand ( ) }
739+
740+ string getFieldName ( ) {
741+ exists ( Input:: FieldAddressInstruction fieldAddr |
742+ this = TOldInstruction ( fieldAddr ) and
743+ result = fieldAddr .getFieldName ( )
744+ )
745+ }
746+
747+ final override string getImmediateValue ( ) { result = this .getFieldName ( ) }
748+ }
749+
735750 private class NewInstruction extends MkInstruction , Instruction {
736751 Opcode opcode ;
737752 TranslatedElement te ;
You can’t perform that action at this time.
0 commit comments