ROSE 0.11.145.147
|
A loader suitable for ELF object files.
An ELF object file typically contains one section per function and each section has a preferred virtual address of zero. This loader will map these sections so they do not overlap in virtual memory.
Definition at line 14 of file BinaryLoaderElfObj.h.
#include <Rose/BinaryAnalysis/BinaryLoaderElfObj.h>
Public Types | |
using | Ptr = BinaryLoaderElfObjPtr |
Reference counting pointer to BinaryLoaderElfObj. | |
Public Types inherited from Rose::BinaryAnalysis::BinaryLoaderElf | |
enum | { VER_FLG_BASE =0x1 , VER_FLG_WEAK =0x2 , VERSYM_HIDDEN =0x8000 } |
Flags for version definitions and requirements. More... | |
using | Ptr = BinaryLoaderElfPtr |
Reference counting pointer to BinaryLoaderElf. | |
Public Types inherited from Rose::BinaryAnalysis::BinaryLoader | |
enum | MappingContribution { CONTRIBUTE_NONE , CONTRIBUTE_ADD , CONTRIBUTE_SUB } |
Describes how a section contributes to the overall memory map. More... | |
enum | ConflictResolution { RESOLVE_THROW , RESOLVE_OVERMAP , RESOLVE_REMAP , RESOLVE_REMAP_ABOVE } |
Describes how conflicts are resolved when mapping a section. More... | |
using | Ptr = BinaryLoaderPtr |
Referenc counting pointer to BinaryLoader. | |
typedef std::vector< Exception > | FixupErrors |
Public Member Functions | |
virtual BinaryLoaderPtr | clone () const override |
Copy constructor. | |
virtual bool | canLoad (SgAsmGenericHeader *) const override |
Capability query. | |
virtual SgAsmGenericSectionPtrList | getRemapSections (SgAsmGenericHeader *) override |
Returns mappable sections in a particular order. | |
virtual MappingContribution | alignValues (SgAsmGenericSection *, const MemoryMap::Ptr &, rose_addr_t *malign_lo, rose_addr_t *malign_hi, rose_addr_t *va, rose_addr_t *mem_size, rose_addr_t *offset, rose_addr_t *file_size, bool *map_private, rose_addr_t *va_offset, bool *anon_lo, bool *anon_hi, ConflictResolution *resolve) override |
Linux-specific ELF Segment and Section alignment. | |
virtual unsigned | mappingPermissions (SgAsmGenericSection *) const override |
MemoryMap permissions. | |
Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoaderElf | |
void | addLibDefaults (SgAsmGenericHeader *header=NULL) |
Sets up library search paths and preloads from the environment. | |
virtual void | fixup (SgAsmInterpretation *interp, FixupErrors *errors=NULL) override |
Performs relocation fixups on the specified interpretation. | |
virtual SgAsmGenericSection * | findSectionByPreferredVa (SgAsmGenericHeader *, rose_addr_t va) |
Find the section containing the specified virtual address. | |
virtual rose_addr_t | rebase (const MemoryMap::Ptr &, SgAsmGenericHeader *, const SgAsmGenericSectionPtrList &) override |
Returns a new, temporary base address which is greater than everything that's been mapped already. | |
Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader | |
void | appendDirectories (const std::vector< std::string > &dirnames) |
Appends directories to the list of directories searched for libraries. | |
virtual std::string | findSoFile (const std::string &libname) const |
Convert name to fully qualified name. | |
virtual void | load (SgAsmInterpretation *) |
Top-level method to do everything. | |
virtual void | link (SgAsmInterpretation *interp) |
Finds and parses all shared objects needed by an interpretation. | |
virtual void | remap (SgAsmInterpretation *interp) |
Maps sections of the interpretation into the virtual address space. | |
virtual std::vector< std::string > | dependencies (SgAsmGenericHeader *) |
Finds shared object dependencies of a single binary header. | |
virtual void | remap (Rose::BinaryAnalysis::MemoryMap::Ptr &, SgAsmGenericHeader *) |
Remaps the sections for a particular header. | |
rose_addr_t | bialign (rose_addr_t val1, rose_addr_t align1, rose_addr_t val2, rose_addr_t align2) |
Calculate adjustment to cause two values to be aligned to two different alignments. | |
virtual void | addSectionsForRemap (SgAsmGenericHeader *header, SgAsmGenericSectionPtrList &allSections) |
Selects loadable sections. | |
bool | performingDynamicLinking () const |
Property: Whether this loader will perform the linking step. | |
void | performingDynamicLinking (bool b) |
Property: Whether this loader will perform the linking step. | |
bool | performingRemap () const |
Property: Whether this loader will perform the mapping step. | |
void | performingRemap (bool b) |
Property: Whether this loader will perform the mapping step. | |
bool | performingRelocations () const |
Property: Whether this loader will perform the relocation step. | |
void | performingRelocations (bool b) |
Property: Whether this loader will perform the relocation step. | |
const std::vector< std::string > & | preloads () const |
Property: List of libraries that will be pre-loaded. | |
std::vector< std::string > & | preloads () |
Property: List of libraries that will be pre-loaded. | |
void | preloads (const std::vector< std::string > &v) |
Property: List of libraries that will be pre-loaded. | |
const std::vector< std::string > & | directories () const |
Property: List of directories searched for libraries. | |
std::vector< std::string > & | directories () |
Property: List of directories searched for libraries. | |
void | directories (const std::vector< std::string > &v) |
Property: List of directories searched for libraries. | |
virtual bool | isLinked (SgBinaryComposite *composite, const std::string &filename) |
Returns true if the specified file name is already linked into the AST. | |
virtual bool | isLinked (SgAsmInterpretation *interp, const std::string &filename) |
Returns true if the specified file name is already linked into the AST. | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. | |
SharedObject (const SharedObject &) | |
Copy constructor. | |
virtual | ~SharedObject () |
Virtual destructor. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
Static Public Member Functions | |
static Ptr | instance () |
Allocating constructor. | |
Static Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoaderElf | |
static Ptr | instance () |
Allocating constructor. | |
static void | getDynamicVars (SgAsmGenericHeader *, std::string &rpath, std::string &runpath) |
Returns the strings associated with certain variables in the ".dynamic" section. | |
Static Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader | |
static Ptr | instance () |
Allocating constructor. | |
static void | initDiagnostics () |
Initialize diagnostic streams for binary loaders. | |
static void | registerSubclass (const Ptr &) |
Register a loader instance. | |
static Ptr | lookup (SgAsmGenericHeader *) |
Finds a suitable loader. | |
static Ptr | lookup (SgAsmInterpretation *) |
Finds a suitable loader. | |
static void | load (SgBinaryComposite *composite, bool read_executable_file_format_only=false) |
Top-level method to do everything. | |
static SgAsmGenericFile * | createAsmAST (SgBinaryComposite *composite, std::string filePath) |
Parses a single binary file. | |
static int64_t | gcd (int64_t a, int64_t b, int64_t *x=NULL, int64_t *y=NULL) |
Extended Euclid Algorithm. | |
static SgAsmGenericHeaderPtrList | findSimilarHeaders (SgAsmGenericHeader *matchHeader, SgAsmGenericHeaderPtrList &candidateHeaders) |
Find headers similar to given header. | |
static bool | isHeaderSimilar (SgAsmGenericHeader *, SgAsmGenericHeader *) |
Determines whether two headers are similar. | |
Protected Member Functions | |
BinaryLoaderElfObj (const BinaryLoaderElfObj &other) | |
Protected Member Functions inherited from Rose::BinaryAnalysis::BinaryLoaderElf | |
BinaryLoaderElf (const BinaryLoaderElf &other) | |
void | buildMasterSymbolTable (SgAsmInterpretation *) |
Builds the master symbol table. | |
SgAsmElfSymbol * | fixupInfoRelocSymbol (SgAsmElfRelocEntry *, const SymverResolver &) |
Returns the defining symbol for a relocation, if any. | |
rose_addr_t | fixupInfoTargetVa (SgAsmElfRelocEntry *, SgAsmGenericSection **section_p=NULL, rose_addr_t *adj_p=NULL) |
Returns the virtual address where a relocation should be supplied. | |
rose_addr_t | fixupInfoSymbolVa (SgAsmElfSymbol *, SgAsmGenericSection **section_p=NULL, rose_addr_t *adj_p=NULL) |
Returns the virtual address of a symbol adjusted for remapping. | |
rose_addr_t | fixupInfoAddend (SgAsmElfRelocEntry *, rose_addr_t target_va, const MemoryMap::Ptr &, size_t nbytes=0) |
Returns the addend associated with a relocation. | |
rose_addr_t | fixupInfoExpr (const std::string &expression, SgAsmElfRelocEntry *reloc, const SymverResolver &resolver, const MemoryMap::Ptr &memmap, rose_addr_t *target_va_p=NULL) |
Evaluates a simple postfix expression and returns the result. | |
void | fixupApply (rose_addr_t value, SgAsmElfRelocEntry *, const MemoryMap::Ptr &, rose_addr_t target_va=0, size_t nbytes=0) |
Writes a value into memory at the relocation target. | |
void | fixupApplySymbolCopy (SgAsmElfRelocEntry *, const SymverResolver &, const MemoryMap::Ptr &) |
Copies symbol memory to the relocation target. | |
void | performRelocation (SgAsmElfRelocEntry *, const SymverResolver &, const MemoryMap::Ptr &) |
void | performRelocations (SgAsmElfFileHeader *, const MemoryMap::Ptr &) |
Protected Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader | |
BinaryLoader (const BinaryLoader &other) | |
Copy constructor. | |
Additional Inherited Members | |
Static Public Attributes inherited from Rose::BinaryAnalysis::BinaryLoader | |
static Sawyer::Message::Facility | mlog |
Logging facility initialized by initDiagnostics(). | |
Protected Attributes inherited from Rose::BinaryAnalysis::BinaryLoaderElf | |
SymbolMap | symbols_ |
Symbol table for an entire interpretation. | |
Reference counting pointer to BinaryLoaderElfObj.
Definition at line 17 of file BinaryLoaderElfObj.h.
|
inlineprotected |
Definition at line 20 of file BinaryLoaderElfObj.h.
|
inlineprotected |
Definition at line 22 of file BinaryLoaderElfObj.h.
|
inlinevirtual |
Definition at line 32 of file BinaryLoaderElfObj.h.
|
inlinestatic |
Allocating constructor.
Definition at line 28 of file BinaryLoaderElfObj.h.
|
inlineoverridevirtual |
Copy constructor.
See super class.
Reimplemented from Rose::BinaryAnalysis::BinaryLoaderElf.
Definition at line 34 of file BinaryLoaderElfObj.h.
|
overridevirtual |
|
overridevirtual |
Returns mappable sections in a particular order.
Returns ELF Segments in the order they are defined in the segment table, followed by ELF Sections in the order they are defined in the section table but excluding those sections that were already added to the list as ELF Segments.
Reimplemented from Rose::BinaryAnalysis::BinaryLoaderElf.
|
overridevirtual |
Linux-specific ELF Segment and Section alignment.
Reimplemented from Rose::BinaryAnalysis::BinaryLoaderElf.
|
overridevirtual |
MemoryMap permissions.
Returns the permissions that should be used when mapping the specified section into memory. The default implementation in the base class uses the access permissions stored in the section. Subclasses can override this method to provide other permissions without resorting to changing the AST (which would be misleading for other analysis).
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.