Skip to content

Commit 104465f

Browse files
committed
Binary: Add a few helper member predicates.
1 parent ee188ac commit 104465f

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/Instruction.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class CallInstruction extends Instruction {
166166

167167
Function getStaticTarget() { result = TMkFunction(te.getStaticCallTarget(tag)) }
168168

169+
CallTargetOperand getTargetOperand() { result = this.getAnOperand() }
170+
169171
override string getImmediateValue() { result = this.getStaticTarget().getName() }
170172
}
171173

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/Operand.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ class ConditionJumpTargetOperand extends Operand {
7171
class JumpTargetOperand extends Operand {
7272
override JumpTargetTag operandTag;
7373
}
74+
75+
class CallTargetOperand extends Operand {
76+
override CallTargetTag operandTag;
77+
}

binary/ql/lib/semmle/code/binary/ast/ir/internal/InstructionSig.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ signature module InstructionSig {
2828
Function getEnclosingFunction();
2929

3030
OperandTag getOperandTag();
31+
32+
Location getLocation();
3133
}
3234

3335
class StoreValueOperand extends Operand;
@@ -48,6 +50,8 @@ signature module InstructionSig {
4850

4951
class RightOperand extends Operand;
5052

53+
class CallTargetOperand extends Operand;
54+
5155
class InstructionTag {
5256
string toString();
5357
}
@@ -160,6 +164,8 @@ signature module InstructionSig {
160164
BasicBlock getBasicBlock();
161165

162166
InstructionTag getInstructionTag();
167+
168+
Operand getFirstOperand();
163169
}
164170

165171
class RetInstruction extends Instruction;
@@ -221,6 +227,12 @@ signature module InstructionSig {
221227
}
222228

223229
class CallInstruction extends Instruction {
230+
CallTargetOperand getTargetOperand();
231+
232+
/**
233+
* Gets the static target of this function call, if it is known (and the
234+
* function exists in the database).
235+
*/
224236
Function getStaticTarget();
225237
}
226238

@@ -248,5 +260,7 @@ signature module InstructionSig {
248260
Function getEnclosingFunction();
249261

250262
Location getLocation();
263+
264+
string toString();
251265
}
252266
}

binary/ql/lib/semmle/code/binary/ast/ir/internal/TransformInstruction/TransformInstruction.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ module Transform<InstructionSig Input> {
659659
)
660660
}
661661

662+
CallTargetOperand getTargetOperand() { result = this.getAnOperand() }
663+
662664
override string getImmediateValue() { result = this.getStaticTarget().getName() }
663665
}
664666

@@ -974,6 +976,10 @@ module Transform<InstructionSig Input> {
974976
LeftOperand() { this.getOperandTag() instanceof LeftTag }
975977
}
976978

979+
class CallTargetOperand extends Operand {
980+
CallTargetOperand() { this.getOperandTag() instanceof CallTargetTag }
981+
}
982+
977983
class RightOperand extends Operand {
978984
RightOperand() { this.getOperandTag() instanceof RightTag }
979985
}

0 commit comments

Comments
 (0)