ROSE  0.9.10.69
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 #include <boost/filesystem.hpp>
9 
10 namespace Rose {
11 namespace BinaryAnalysis {
12 namespace Partitioner2 {
13 namespace ModulesElf {
14 
21 std::vector<Function::Ptr> findErrorHandlingFunctions(SgAsmElfFileHeader*);
22 std::vector<Function::Ptr> findErrorHandlingFunctions(SgAsmInterpretation*);
23 size_t findErrorHandlingFunctions(SgAsmElfFileHeader*, std::vector<Function::Ptr>&);
29 std::vector<Function::Ptr> findPltFunctions(const Partitioner&, SgAsmElfFileHeader*);
30 std::vector<Function::Ptr> findPltFunctions(const Partitioner&, SgAsmInterpretation*);
31 size_t findPltFunctions(const Partitioner&, SgAsmElfFileHeader*, std::vector<Function::Ptr>&);
38 bool isImport(const Partitioner&, const Function::Ptr&);
39 
44 bool isLinkedImport(const Partitioner&, const Function::Ptr&);
45 
49 bool isUnlinkedImport(const Partitioner&, const Function::Ptr&);
50 
55 bool isObjectFile(const boost::filesystem::path&);
56 
61 bool isStaticArchive(const boost::filesystem::path&);
62 
64 namespace FixUndefinedSymbols {
66 enum Boolean {
67  NO,
68  YES
69 };
70 } // namespace
71 
76 bool tryLink(const std::string &command, std::string outputName, std::vector<std::string> inputNames,
78 
82  rose_addr_t baseVa_; // base address for computing memAddress_
83  rose_addr_t gotEntryVa_; // address through which an indirect branch branches
84  size_t gotEntryNBytes_; // size of the global offset table entry in bytes
85  rose_addr_t gotEntry_; // address read from the GOT if the address is mapped (or zero)
86  size_t nBytesMatched_; // number of bytes matched for PLT entry
87 
88 public:
89  PltEntryMatcher(rose_addr_t base)
90  : baseVa_(base), gotEntryVa_(0), gotEntryNBytes_(0), gotEntry_(0), nBytesMatched_(0) {}
91  static Ptr instance(rose_addr_t base) { return Ptr(new PltEntryMatcher(base)); }
92  virtual bool match(const Partitioner&, rose_addr_t anchor);
93 
95  size_t nBytesMatched() const { return nBytesMatched_; }
96 
98  rose_addr_t gotEntryVa() const { return gotEntryVa_; }
99 
101  size_t gotEntryNBytes() const { return gotEntryNBytes_; }
102 
104  rose_addr_t gotEntry() const { return gotEntry_; }
105 
106  // [Robb Matzke 2018-04-06]: deprecated: use gotEntryVa
107  rose_addr_t memAddress() const { return gotEntryVa_; }
108 };
109 
111 void buildMayReturnLists(Partitioner&);
112 
113 } // namespace
114 } // namespace
115 } // namespace
116 } // namespace
117 
118 #endif
rose_addr_t gotEntry() const
Value stored in the GOT entry.
Definition: ModulesElf.h:104
Represents the file header of an ELF binary container.
rose_addr_t gotEntryVa() const
Address of the corresponding GOT entry.
Definition: ModulesElf.h:98
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:95
Sawyer::SharedPointer< InstructionMatcher > Ptr
Shared-ownership pointer to an InstructionMatcher.
Definition: Modules.h:80
Converts text to messages.
Definition: Message.h:1394
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:101