1#ifndef ROSE_BinaryAnalysis_BinaryLoaderElf_H
2#define ROSE_BinaryAnalysis_BinaryLoaderElf_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/BinaryLoader.h>
8namespace BinaryAnalysis {
40 : symbol_(
symbol), versionEntry_(NULL), versionDef_(NULL), versionNeed_(NULL)
97 void print(std::ostream&)
const;
100 void dump(FILE*,
const char *prefix, ssize_t idx)
const;
108 std::vector<VersionedSymbol> versions_;
132 void dump(FILE*,
const char *prefix)
const ;
139 class SymbolMap:
public std::map<std::string, SymbolMapEntry> {
150 void dump(FILE*,
const char *prefix)
const;
155 typedef std::map<SgAsmElfSymbol*, VersionedSymbol*> VersionedSymbolMap;
156 typedef std::map<uint16_t, SgAsmElfSymverDefinedEntry*> SymbolVersionDefinitionMap;
157 typedef std::map<uint16_t, SgAsmElfSymverNeededAux*> SymbolVersionNeededMap;
161 SymbolVersionDefinitionMap symbolVersionDefMap_;
167 SymbolVersionNeededMap symbolVersionNeedMap_;
170 VersionedSymbolMap versionedSymbolMap_;
181 void dump(FILE*,
const char *prefix, ssize_t idx)
const;
273 rose_addr_t *malign_lo, rose_addr_t *malign_hi,
274 rose_addr_t *va, rose_addr_t *mem_size,
275 rose_addr_t *offset, rose_addr_t *file_size,
bool *map_private,
276 rose_addr_t *va_offset,
bool *anon_lo,
bool *anon_hi,
A mapping from symbol name (with optional version in parentheses) to SymbolMapEntry.
const SymbolMapEntry * lookup(std::string name, std::string version) const
Finds and returns the entry having the specified name and version.
void dump(FILE *, const char *prefix) const
Print debugging information about this SymbolMap.
const SymbolMapEntry * lookup(std::string name) const
Finds and returns the entry having the specified name.
void dump(FILE *, const char *prefix, ssize_t idx) const
Print some info about the resolver.
VersionedSymbol getVersionedSymbol(SgAsmElfSymbol *symbol) const
Returns the VersionedSymbol corresponding to the specified symbol.
Symbol from .dynsym combined with additional information.
SgAsmElfSymverNeededAux * versionNeed() const
Property: The version requirement of this symbol.
void print(std::ostream &) const
Print used by operator<<.
void dump(FILE *, const char *prefix, ssize_t idx) const
Dump info like for SgAsm* objects.
SgAsmElfSymbolSection * getSection() const
Returns the symbol section (.dynsym) where this symbol was defined.
bool isBaseDefinition() const
Returns tru if this symbol is a base definition.
void versionEntry(SgAsmElfSymverEntry *)
Property: Version pointer for this symbol.
bool isLocal() const
Returns true if this symbol is visible only locally.
std::string getVersion() const
Returns the version string of this symbol.
std::string getVersionedName() const
Returns the full, versionioned name of this symbol.
bool isHidden() const
Returns true if this symbol is hidden.
void symbol(SgAsmElfSymbol *symbol)
Property: The symbol.
std::string getName() const
Returns the name of this symbol.
SgAsmElfSymbol * symbol() const
Property: The symbol.
bool isReference() const
Returns true if this symbol is a reference to an object rather than the definition of the object.
void versionNeed(SgAsmElfSymverNeededAux *)
Property: The version requirement of this symbol.
SgAsmElfSymverDefinedEntry * versionDef() const
Property: Version definition of this symbol.
void versionDef(SgAsmElfSymverDefinedEntry *)
Property: Version definition of this symbol.
virtual BinaryLoaderPtr clone() const override
Copy constructor.
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.
virtual SgAsmGenericSection * findSectionByPreferredVa(SgAsmGenericHeader *, rose_addr_t va)
Find the section containing the specified virtual address.
SymbolMap symbols_
Symbol table for an entire interpretation.
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 fixupApplySymbolCopy(SgAsmElfRelocEntry *, const SymverResolver &, const MemoryMap::Ptr &)
Copies symbol memory to the relocation target.
void buildMasterSymbolTable(SgAsmInterpretation *)
Builds the master symbol table.
static void getDynamicVars(SgAsmGenericHeader *, std::string &rpath, std::string &runpath)
Returns the strings associated with certain variables in the ".dynamic" section.
virtual bool canLoad(SgAsmGenericHeader *) const override
Capability query.
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.
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 SgAsmGenericSectionPtrList getRemapSections(SgAsmGenericHeader *) override
Returns mappable sections in a particular order.
BinaryLoaderElfPtr Ptr
Reference counting pointer to BinaryLoaderElf.
void addLibDefaults(SgAsmGenericHeader *header=NULL)
Sets up library search paths and preloads from the environment.
rose_addr_t fixupInfoAddend(SgAsmElfRelocEntry *, rose_addr_t target_va, const MemoryMap::Ptr &, size_t nbytes=0)
Returns the addend associated with a relocation.
static Ptr instance()
Allocating constructor.
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.
SgAsmElfSymbol * fixupInfoRelocSymbol(SgAsmElfRelocEntry *, const SymverResolver &)
Returns the defining symbol for a relocation, if any.
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.
virtual void fixup(SgAsmInterpretation *interp, FixupErrors *errors=NULL) override
Performs relocation fixups on the specified interpretation.
Base class for loading a static or dynamic object.
MappingContribution
Describes how a section contributes to the overall memory map.
ConflictResolution
Describes how conflicts are resolved when mapping a section.
Reference-counting intrusive smart pointer.
One entry of an ELF relocation table.
ELF file section containing symbols.
Represents a single ELF symbol.
One entry from an ELF symbol version definition table.
The GNU symbol version definitions.
Entry in an ELF symbol version table.
Auxiliary info for needed symbol version.
GNU symbol version requirements table.
The ELF symbol version table.
Contiguous region of a file.
Represents an interpretation of a binary container.
Sawyer::SharedPointer< BinaryLoaderElf > BinaryLoaderElfPtr
Reference counting pointer.
Sawyer::SharedPointer< BinaryLoader > BinaryLoaderPtr
Reference counting pointer.
An entry for a SymbolMap.
void merge(const SymbolMapEntry &)
Merge the versions from the specified entry into this entry.
void dump(FILE *, const char *prefix) const
Print info about this symbol map entry.
VersionedSymbol getVSymbol(const VersionedSymbol &version) const
Find definition of symbol.
SgAsmElfSymbol * getSymbol() const
Returns the ELF symbol from the base version.
void addVersion(const VersionedSymbol &vsymbol)
Add an additional versioned symbol to this entry.
SgAsmElfSymbolSection * getSection() const
Returns the section where the base version symbol was defined.
const VersionedSymbol & getVSymbol() const
Returns the base version.