1 #ifndef ROSE_BinaryAnalysis_Partitioner2_ModulesElf_H
2 #define ROSE_BinaryAnalysis_Partitioner2_ModulesElf_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/Partitioner2/Function.h>
8 #include <Rose/BinaryAnalysis/Partitioner2/Modules.h>
10 #include <boost/filesystem.hpp>
13 namespace BinaryAnalysis {
14 namespace Partitioner2 {
17 namespace ModulesElf {
45 : section(NULL), firstOffset(0), entrySize(0) {}
86 namespace FixUndefinedSymbols {
98 bool tryLink(
const std::string &command,
const boost::filesystem::path &outputName,
107 std::vector<boost::filesystem::path>
108 extractStaticArchive(
const boost::filesystem::path &directory,
const boost::filesystem::path &archive);
114 rose_addr_t gotVa_ = 0;
115 rose_addr_t gotEntryVa_ = 0;
116 size_t gotEntryNBytes_ = 0;
117 rose_addr_t gotEntry_ = 0;
118 size_t nBytesMatched_ = 0;
119 rose_addr_t functionNumber_ = 0;
120 rose_addr_t pltEntryAlignment_ = 1;
125 static Ptr instance(rose_addr_t gotVa) {
131 rose_addr_t
gotVa()
const {
return gotVa_; }
153 rose_addr_t &indirectVa ,
size_t &indirectNBytes );
155 rose_addr_t &offsetFromEbx ,
size_t &indirectNBytes );
158 rose_addr_t &indirectNBytes );
std::vector< FunctionPtr > findErrorHandlingFunctions(SgAsmElfFileHeader *)
Reads ELF .eh_frames to find function entry addresses.
std::vector< SgAsmElfSection * > findSectionsByName(SgAsmInterpretation *, const std::string &)
Get a list of all ELF sections by name.
Contiguous region of a file.
bool tryLink(const std::string &command, const boost::filesystem::path &outputName, std::vector< boost::filesystem::path > inputNames, Sawyer::Message::Stream &errors, FixUndefinedSymbols::Boolean fixUndefinedSymbols=FixUndefinedSymbols::YES)
Try to run a link command.
rose_addr_t gotEntry() const
Value stored in the GOT entry.
bool isObjectFile(const boost::filesystem::path &)
True if named file is an ELF object file.
Matches an ELF PLT entry.
bool isStaticArchive(const boost::filesystem::path &)
True if named file is a static library archive.
Base class for machine instructions.
PltInfo findPlt(const PartitionerConstPtr &, SgAsmGenericSection *, SgAsmElfFileHeader *)
Find information about the PLT.
rose_addr_t gotEntryVa() const
Address of the corresponding GOT entry.
std::vector< boost::filesystem::path > extractStaticArchive(const boost::filesystem::path &directory, const boost::filesystem::path &archive)
Extract object files from a static archive.
void buildMayReturnLists(const PartitionerPtr &)
Build may-return white and black lists.
Information about the procedure lookup table.
size_t entrySize
Size of each entry in bytes.
Yes, try to fix undefined symbols.
Main namespace for the ROSE library.
Base class for matching an instruction pattern.
Reference-counting intrusive smart pointer.
virtual bool match(const PartitionerConstPtr &, rose_addr_t anchor)
Attempt to match an instruction pattern.
rose_addr_t pltEntryAlignment() const
Alignment of PLT entries w.r.t.
Boolean
Boolean flag for tryLink.
rose_addr_t gotVa() const
Address of global offset table.
std::vector< FunctionPtr > findPltFunctions(const PartitionerPtr &, SgAsmElfFileHeader *)
Reads ELF PLT sections and returns a list of functions.
bool isLinkedImport(const PartitionerConstPtr &, const FunctionPtr &)
True if function is a linked import.
bool isUnlinkedImport(const PartitionerConstPtr &, const FunctionPtr &)
True if function is a non-linked import.
size_t nBytesMatched() const
Size of the PLT entry in bytes.
Sawyer::SharedPointer< InstructionMatcher > Ptr
Shared-ownership pointer to an InstructionMatcher.
Converts text to messages.
Represents an interpretation of a binary container.
bool isImport(const PartitionerConstPtr &, const FunctionPtr &)
True if the function is an import.
size_t firstOffset
Byte offset w.r.t.
size_t gotEntryNBytes() const
Size of the GOT entry in bytes.
Do not try to fix undefined symbols.