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>
13namespace BinaryAnalysis {
14namespace Partitioner2 {
86namespace FixUndefinedSymbols {
98bool tryLink(
const std::string &command,
const boost::filesystem::path &outputName,
107std::vector<boost::filesystem::path>
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 );
Base class for matching an instruction pattern.
Sawyer::SharedPointer< InstructionMatcher > Ptr
Shared-ownership pointer to an InstructionMatcher.
Converts text to messages.
Reference-counting intrusive smart pointer.
Contiguous region of a file.
Base class for machine instructions.
Represents an interpretation of a binary container.
Boolean
Boolean flag for Rose::BinaryAnalysis::Partitioner2::ModulesElf::tryLink.
@ YES
Yes, try to fix undefined symbols.
@ NO
Do not try to fix undefined symbols.
bool isImport(const PartitionerConstPtr &, const FunctionPtr &)
True if the function is an import.
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.
bool isObjectFile(const boost::filesystem::path &)
True if named file is an ELF object 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.
PltInfo findPlt(const PartitionerConstPtr &, SgAsmGenericSection *, SgAsmElfFileHeader *)
Find information about the PLT.
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.
void buildMayReturnLists(const PartitionerPtr &)
Build may-return white and black lists.
std::vector< boost::filesystem::path > extractStaticArchive(const boost::filesystem::path &directory, const boost::filesystem::path &archive)
Extract object files from a static archive.
bool isStaticArchive(const boost::filesystem::path &)
True if named file is a static library archive.
bool isUnlinkedImport(const PartitionerConstPtr &, const FunctionPtr &)
True if function is a non-linked import.
Matches an ELF PLT entry.
rose_addr_t gotEntry() const
Value stored in the GOT entry.
virtual bool match(const PartitionerConstPtr &, rose_addr_t anchor)
Attempt to match an instruction pattern.
rose_addr_t gotVa() const
Address of global offset table.
size_t nBytesMatched() const
Size of the PLT entry in bytes.
size_t gotEntryNBytes() const
Size of the GOT entry in bytes.
rose_addr_t pltEntryAlignment() const
Alignment of PLT entries w.r.t.
rose_addr_t gotEntryVa() const
Address of the corresponding GOT entry.
Information about the procedure lookup table.
size_t entrySize
Size of each entry in bytes.
size_t firstOffset
Byte offset w.r.t.