ROSE  0.9.10.27
ModulesElf.h
1 #ifndef ROSE_Partitioner2_ModulesElf_H
2 #define ROSE_Partitioner2_ModulesElf_H
3 
4 #include <Partitioner2/BasicTypes.h>
5 #include <Partitioner2/Function.h>
6 #include <Partitioner2/Modules.h>
7 
8 namespace Rose {
9 namespace BinaryAnalysis {
10 namespace Partitioner2 {
11 namespace ModulesElf {
12 
19 std::vector<Function::Ptr> findErrorHandlingFunctions(SgAsmElfFileHeader*);
20 std::vector<Function::Ptr> findErrorHandlingFunctions(SgAsmInterpretation*);
21 size_t findErrorHandlingFunctions(SgAsmElfFileHeader*, std::vector<Function::Ptr>&);
27 std::vector<Function::Ptr> findPltFunctions(const Partitioner&, SgAsmElfFileHeader*);
28 std::vector<Function::Ptr> findPltFunctions(const Partitioner&, SgAsmInterpretation*);
29 size_t findPltFunctions(const Partitioner&, SgAsmElfFileHeader*, std::vector<Function::Ptr>&);
36 bool isImport(const Partitioner&, const Function::Ptr&);
37 
42 bool isLinkedImport(const Partitioner&, const Function::Ptr&);
43 
47 bool isUnlinkedImport(const Partitioner&, const Function::Ptr&);
48 
52  rose_addr_t baseVa_; // base address for computing memAddress_
53  rose_addr_t gotEntryVa_; // address through which an indirect branch branches
54  size_t gotEntryNBytes_; // size of the global offset table entry in bytes
55  rose_addr_t gotEntry_; // address read from the GOT if the address is mapped (or zero)
56  size_t nBytesMatched_; // number of bytes matched for PLT entry
57 
58 public:
59  PltEntryMatcher(rose_addr_t base)
60  : baseVa_(base), gotEntryVa_(0), gotEntryNBytes_(0), gotEntry_(0), nBytesMatched_(0) {}
61  static Ptr instance(rose_addr_t base) { return Ptr(new PltEntryMatcher(base)); }
62  virtual bool match(const Partitioner&, rose_addr_t anchor);
63 
65  size_t nBytesMatched() const { return nBytesMatched_; }
66 
68  rose_addr_t gotEntryVa() const { return gotEntryVa_; }
69 
71  size_t gotEntryNBytes() const { return gotEntryNBytes_; }
72 
74  rose_addr_t gotEntry() const { return gotEntry_; }
75 
76  // [Robb Matzke 2018-04-06]: deprecated: use gotEntryVa
77  rose_addr_t memAddress() const { return gotEntryVa_; }
78 };
79 
81 void buildMayReturnLists(Partitioner&);
82 
83 } // namespace
84 } // namespace
85 } // namespace
86 } // namespace
87 
88 #endif
rose_addr_t gotEntry() const
Value stored in the GOT entry.
Definition: ModulesElf.h:74
Represents the file header of an ELF binary container.
rose_addr_t gotEntryVa() const
Address of the corresponding GOT entry.
Definition: ModulesElf.h:68
Main namespace for the ROSE library.
Base class for matching an instruction pattern.
Definition: Modules.h:77
Reference-counting smart pointer.
Definition: SharedPointer.h:34
virtual bool match(const Partitioner &, rose_addr_t anchor)
Attempt to match an instruction pattern.
size_t nBytesMatched() const
Size of the PLT entry in bytes.
Definition: ModulesElf.h:65
Sawyer::SharedPointer< InstructionMatcher > Ptr
Shared-ownership pointer to an InstructionMatcher.
Definition: Modules.h:80
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:292
FunctionPtr Ptr
Shared-ownership pointer for function.
Definition: Function.h:48
Represents an interpretation of a binary container.
size_t gotEntryNBytes() const
Size of the GOT entry in bytes.
Definition: ModulesElf.h:71