ROSE  0.9.10.168
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::BinaryLoaderElfObj Class Reference

Description

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 16 of file BinaryLoaderElfObj.h.

#include <BinaryLoaderElfObj.h>

Inheritance diagram for Rose::BinaryAnalysis::BinaryLoaderElfObj:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::BinaryLoaderElfObj:
Collaboration graph
[legend]

Public Types

typedef Sawyer::SharedPointer< class BinaryLoaderElfObjPtr
 Reference counting pointer to BinaryLoaderElfObj. More...
 
- 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...
 
typedef Sawyer::SharedPointer< class BinaryLoaderElfPtr
 Reference counting pointer to BinaryLoaderElf. More...
 
- 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...
 
typedef Sawyer::SharedPointer< BinaryLoaderPtr
 Referenc counting pointer to BinaryLoader. More...
 
typedef std::vector< ExceptionFixupErrors
 

Public Member Functions

virtual BinaryLoaderPtr clone () const ROSE_OVERRIDE
 Copy constructor. More...
 
virtual bool canLoad (SgAsmGenericHeader *) const ROSE_OVERRIDE
 Capability query. More...
 
virtual SgAsmGenericSectionPtrList getRemapSections (SgAsmGenericHeader *) ROSE_OVERRIDE
 Returns mappable sections in a particular order. More...
 
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) ROSE_OVERRIDE
 Linux-specific ELF Segment and Section alignment. More...
 
virtual unsigned mappingPermissions (SgAsmGenericSection *) const ROSE_OVERRIDE
 MemoryMap permissions. More...
 
- Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoaderElf
void addLibDefaults (SgAsmGenericHeader *header=NULL)
 Sets up library search paths and preloads from the environment. More...
 
virtual void fixup (SgAsmInterpretation *interp, FixupErrors *errors=NULL) ROSE_OVERRIDE
 Performs relocation fixups on the specified interpretation. More...
 
virtual SgAsmGenericSectionfindSectionByPreferredVa (SgAsmGenericHeader *, rose_addr_t va)
 Find the section containing the specified virtual address. More...
 
virtual rose_addr_t rebase (const MemoryMap::Ptr &, SgAsmGenericHeader *, const SgAsmGenericSectionPtrList &) ROSE_OVERRIDE
 Returns a new, temporary base address which is greater than everything that's been mapped already. More...
 
- 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. More...
 
virtual std::string findSoFile (const std::string &libname) const
 Convert name to fully qualified name. More...
 
virtual void load (SgAsmInterpretation *)
 Top-level method to do everything. More...
 
virtual void link (SgAsmInterpretation *interp)
 Finds and parses all shared objects needed by an interpretation. More...
 
virtual void remap (SgAsmInterpretation *interp)
 Maps sections of the interpretation into the virtual address space. More...
 
virtual std::vector< std::string > dependencies (SgAsmGenericHeader *)
 Finds shared object dependencies of a single binary header. More...
 
virtual void remap (Rose::BinaryAnalysis::MemoryMap::Ptr &, SgAsmGenericHeader *)
 Remaps the sections for a particular header. More...
 
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. More...
 
virtual void addSectionsForRemap (SgAsmGenericHeader *header, SgAsmGenericSectionPtrList &allSections)
 Selects loadable sections. More...
 
bool performingDynamicLinking () const
 Property: Whether this loader will perform the linking step. More...
 
void performingDynamicLinking (bool b)
 Property: Whether this loader will perform the linking step. More...
 
bool performingRemap () const
 Property: Whether this loader will perform the mapping step. More...
 
void performingRemap (bool b)
 Property: Whether this loader will perform the mapping step. More...
 
bool performingRelocations () const
 Property: Whether this loader will perform the relocation step. More...
 
void performingRelocations (bool b)
 Property: Whether this loader will perform the relocation step. More...
 
const std::vector< std::string > & preloads () const
 Property: List of libraries that will be pre-loaded. More...
 
std::vector< std::string > & preloads ()
 Property: List of libraries that will be pre-loaded. More...
 
void preloads (const std::vector< std::string > &v)
 Property: List of libraries that will be pre-loaded. More...
 
const std::vector< std::string > & directories () const
 Property: List of directories searched for libraries. More...
 
std::vector< std::string > & directories ()
 Property: List of directories searched for libraries. More...
 
void directories (const std::vector< std::string > &v)
 Property: List of directories searched for libraries. More...
 
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. More...
 
 SharedObject (const SharedObject &)
 Copy constructor. More...
 
virtual ~SharedObject ()
 Virtual destructor. More...
 
SharedObjectoperator= (const SharedObject &)
 Assignment. More...
 

Static Public Member Functions

static Ptr instance ()
 Allocating constructor. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoaderElf
static Ptr instance ()
 Allocating constructor. More...
 
static void getDynamicVars (SgAsmGenericHeader *, std::string &rpath, std::string &runpath)
 Returns the strings associated with certain variables in the ".dynamic" section. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader
static Ptr instance ()
 Allocating constructor. More...
 
static void initDiagnostics ()
 Initialize diagnostic streams for binary loaders. More...
 
static void registerSubclass (const Ptr &)
 Register a loader instance. More...
 
static Ptr lookup (SgAsmGenericHeader *)
 Finds a suitable loader. More...
 
static Ptr lookup (SgAsmInterpretation *)
 Finds a suitable loader. More...
 
static void load (SgBinaryComposite *composite, bool read_executable_file_format_only=false)
 Top-level method to do everything. More...
 
static SgAsmGenericFilecreateAsmAST (SgBinaryComposite *composite, std::string filePath)
 Parses a single binary file. More...
 
static int64_t gcd (int64_t a, int64_t b, int64_t *x=NULL, int64_t *y=NULL)
 Extended Euclid Algorithm. More...
 
static SgAsmGenericHeaderPtrList findSimilarHeaders (SgAsmGenericHeader *matchHeader, SgAsmGenericHeaderPtrList &candidateHeaders)
 Find headers similar to given header. More...
 
static bool isHeaderSimilar (SgAsmGenericHeader *, SgAsmGenericHeader *)
 Determines whether two headers are similar. More...
 

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. More...
 
SgAsmElfSymbolfixupInfoRelocSymbol (SgAsmElfRelocEntry *, const SymverResolver &)
 Returns the defining symbol for a relocation, if any. More...
 
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. More...
 
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. More...
 
rose_addr_t fixupInfoAddend (SgAsmElfRelocEntry *, rose_addr_t target_va, const MemoryMap::Ptr &, size_t nbytes=0)
 Returns the addend associated with a relocation. More...
 
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. More...
 
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. More...
 
void fixupApplySymbolCopy (SgAsmElfRelocEntry *, const SymverResolver &, const MemoryMap::Ptr &)
 Copies symbol memory to the relocation target. More...
 
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. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Rose::BinaryAnalysis::BinaryLoader
static Sawyer::Message::Facility mlog
 Logging facility initialized by initDiagnostics(). More...
 
- Protected Attributes inherited from Rose::BinaryAnalysis::BinaryLoaderElf
SymbolMap symbols_
 Symbol table for an entire interpretation. More...
 

Member Typedef Documentation

Reference counting pointer to BinaryLoaderElfObj.

Definition at line 19 of file BinaryLoaderElfObj.h.

Member Function Documentation

static Ptr Rose::BinaryAnalysis::BinaryLoaderElfObj::instance ( )
inlinestatic

Allocating constructor.

Definition at line 30 of file BinaryLoaderElfObj.h.

virtual BinaryLoaderPtr Rose::BinaryAnalysis::BinaryLoaderElfObj::clone ( ) const
inlinevirtual

Copy constructor.

See super class.

Reimplemented from Rose::BinaryAnalysis::BinaryLoaderElf.

Definition at line 36 of file BinaryLoaderElfObj.h.

virtual bool Rose::BinaryAnalysis::BinaryLoaderElfObj::canLoad ( SgAsmGenericHeader ) const
virtual

Capability query.

See super class.

Reimplemented from Rose::BinaryAnalysis::BinaryLoaderElf.

virtual SgAsmGenericSectionPtrList Rose::BinaryAnalysis::BinaryLoaderElfObj::getRemapSections ( SgAsmGenericHeader )
virtual

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.

virtual MappingContribution Rose::BinaryAnalysis::BinaryLoaderElfObj::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 
)
virtual

Linux-specific ELF Segment and Section alignment.

Reimplemented from Rose::BinaryAnalysis::BinaryLoaderElf.

virtual unsigned Rose::BinaryAnalysis::BinaryLoaderElfObj::mappingPermissions ( SgAsmGenericSection ) const
virtual

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.


The documentation for this class was generated from the following file: