1 #ifndef ROSE_BinaryAnalysis_Partitioner2_Thunk_H
2 #define ROSE_BinaryAnalysis_Partitioner2_Thunk_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
7 #include <Sawyer/SharedObject.h>
10 namespace BinaryAnalysis {
11 namespace Partitioner2 {
31 : nInsns(nInsns), name(name) {}
36 void this_type_does_not_support_comparisons()
const {}
38 operator unspecified_bool()
const {
39 return nInsns ? &ThunkDetection::this_type_does_not_support_comparisons : 0;
46 ThunkDetection
isX86JmpImmThunk(
const Partitioner&,
const std::vector<SgAsmInstruction*>&);
51 ThunkDetection
isX86JmpMemThunk(
const Partitioner&,
const std::vector<SgAsmInstruction*>&);
56 ThunkDetection
isX86LeaJmpThunk(
const Partitioner&,
const std::vector<SgAsmInstruction*>&);
61 ThunkDetection
isX86MovJmpThunk(
const Partitioner&,
const std::vector<SgAsmInstruction*>&);
66 ThunkDetection
isX86AddJmpThunk(
const Partitioner&,
const std::vector<SgAsmInstruction*>&);
88 std::vector<ThunkPredicate> predicates_;
114 const std::vector<ThunkPredicate>&
predicates()
const {
return predicates_; }
115 std::vector<ThunkPredicate>&
predicates() {
return predicates_; }
std::string name
Name of the pattern that matched the instructions.
ThunkDetection(size_t nInsns, const std::string &name)
Constructor for a detected thunk.
ThunkDetection isX86JmpMemThunk(const Partitioner &, const std::vector< SgAsmInstruction * > &)
Test whether x86 instruction begin with "jmp [ADDRESS]".
ThunkDetection()
Constructor for detecting no thunk.
Main namespace for the ROSE library.
ThunkDetection(* ThunkPredicate)(const Partitioner &, const std::vector< SgAsmInstruction * > &)
Function signature for finding thunks.
std::vector< ThunkPredicate > & predicates()
Property: The list of predicates that will test for thunks.
ThunkDetection isX86MovJmpThunk(const Partitioner &, const std::vector< SgAsmInstruction * > &)
Test whether x86 instructions begin with "mov R, [ADDR]; jmp R".
const std::vector< ThunkPredicate > & predicates() const
Property: The list of predicates that will test for thunks.
static Ptr functionMatcherThunks()
Construct collective predicate for matching thunks to create functions.
Return type for thunk detectors.
ThunkDetection isThunk(const Partitioner &, const std::vector< SgAsmInstruction * > &) const
Test whether instructions begin with a thunk.
static Ptr instance()
Allocating constructor.
ThunkDetection isX86LeaJmpThunk(const Partitioner &, const std::vector< SgAsmInstruction * > &)
Test whether x86 instructions begin with an LEA JMP pair.
Base class for reference counted objects.
static Ptr allThunks()
Construct collective predicate with all built-in predicates.
void splitThunkFunctions(Partitioner &, const ThunkPredicates::Ptr &)
Split thunks off from start of functions.
ThunkDetection isX86AddJmpThunk(const Partitioner &, const std::vector< SgAsmInstruction * > &)
Test whether x86 instructions begin with "add R, C; jmp ADDR".
List of thunk predicates.
Partitions instructions into basic blocks and functions.
ThunkDetection isX86JmpImmThunk(const Partitioner &, const std::vector< SgAsmInstruction * > &)
Test whether x86 instructions begin with "jmp ADDRESS".
size_t nInsns
Number of instructions that are part of the thunk.