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>
8 namespace BinaryAnalysis {
40 : symbol_(symbol), versionEntry_(NULL), versionDef_(NULL), versionNeed_(NULL)
66 ASSERT_not_null(retval);
83 versionEntry_ = entry;
115 void print(std::ostream&)
const;
118 void dump(FILE*,
const char *prefix, ssize_t idx)
const;
126 std::vector<VersionedSymbol> versions_;
130 return getBaseVersion();
156 void dump(FILE*,
const char *prefix)
const ;
160 ASSERT_forbid(versions_.empty());
161 return versions_.front();
166 class SymbolMap:
public std::map<std::string, SymbolMapEntry> {
177 void dump(FILE*,
const char *prefix)
const;
182 typedef std::map<SgAsmElfSymbol*, VersionedSymbol*> VersionedSymbolMap;
183 typedef std::map<uint16_t, SgAsmElfSymverDefinedEntry*> SymbolVersionDefinitionMap;
184 typedef std::map<uint16_t, SgAsmElfSymverNeededAux*> SymbolVersionNeededMap;
188 SymbolVersionDefinitionMap symbolVersionDefMap_;
194 SymbolVersionNeededMap symbolVersionNeedMap_;
197 VersionedSymbolMap versionedSymbolMap_;
208 void dump(FILE*,
const char *prefix, ssize_t idx)
const;
300 rose_addr_t *malign_lo, rose_addr_t *malign_hi,
301 rose_addr_t *va, rose_addr_t *mem_size,
302 rose_addr_t *offset, rose_addr_t *file_size,
bool *map_private,
303 rose_addr_t *va_offset,
bool *anon_lo,
bool *anon_hi,
424 std::ostream& operator<<(std::ostream&,
const BinaryLoaderElf::VersionedSymbol&);
The GNU symbol version definitions.
SgAsmElfSymverNeededAux * versionNeed() const
Property: The version requirement of this symbol.
virtual SgAsmGenericSection * findSectionByPreferredVa(SgAsmGenericHeader *, rose_addr_t va)
Find the section containing the specified virtual address.
int const & get_flags() const
Property: Flags.
void versionNeed(SgAsmElfSymverNeededAux *need)
Property: The version requirement of this symbol.
bool isReference() const
Returns true if this symbol is a reference to an object rather than the definition of the object...
Contiguous region of a file.
void dump(FILE *, const char *prefix) const
Print debugging information about this SymbolMap.
Auxiliary info for needed symbol version.
One entry of an ELF relocation table.
const VersionedSymbol & getVSymbol() const
Returns the base version.
SgAsmElfSymbol * fixupInfoRelocSymbol(SgAsmElfRelocEntry *, const SymverResolver &)
Returns the defining symbol for a relocation, if any.
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.
void merge(const SymbolMapEntry &)
Merge the versions from the specified entry into this entry.
Sawyer::SharedPointer< BinaryLoader > BinaryLoaderPtr
Reference counting pointer.
SgAsmElfSymbol * symbol() const
Property: The symbol.
virtual BinaryLoaderPtr clone() const override
Copy constructor.
SgAsmElfSymbolSection * getSection() const
Returns the symbol section (.dynsym) where this symbol was defined.
Main namespace for the ROSE library.
Entry in an ELF symbol version table.
VersionedSymbol getVersionedSymbol(SgAsmElfSymbol *symbol) const
Returns the VersionedSymbol corresponding to the specified symbol.
static void getDynamicVars(SgAsmGenericHeader *, std::string &rpath, std::string &runpath)
Returns the strings associated with certain variables in the ".dynamic" section.
SgAsmElfSymbolSection * getSection() const
Returns the section where the base version symbol was defined.
GNU symbol version requirements table.
rose_addr_t fixupInfoAddend(SgAsmElfRelocEntry *, rose_addr_t target_va, const MemoryMap::Ptr &, size_t nbytes=0)
Returns the addend associated with a relocation.
An entry for a SymbolMap.
int const & get_flags() const
Property: Flags.
virtual void fixup(SgAsmInterpretation *interp, FixupErrors *errors=NULL) override
Performs relocation fixups on the specified interpretation.
A mapping from symbol name (with optional version in parentheses) to SymbolMapEntry.
void addLibDefaults(SgAsmGenericHeader *header=NULL)
Sets up library search paths and preloads from the environment.
static Ptr instance()
Allocating constructor.
const SymbolMapEntry * lookup(std::string name) const
Finds and returns the entry having the specified name.
void versionDef(SgAsmElfSymverDefinedEntry *def)
Property: Version definition of this symbol.
ELF file section containing symbols.
void symbol(SgAsmElfSymbol *symbol)
Property: The symbol.
bool isHidden() const
Returns true if this symbol is hidden.
One entry from an ELF symbol version definition table.
Represents a single ELF symbol.
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.
SgAsmGenericString * get_name() const
Property: Name.
void versionEntry(SgAsmElfSymverEntry *entry)
Property: Version pointer for this symbol.
Sawyer::SharedPointer< BinaryLoaderElf > BinaryLoaderElfPtr
Reference counting pointer.
MappingContribution
Describes how a section contributes to the overall memory map.
BinaryLoaderElfPtr Ptr
Reference counting pointer to BinaryLoaderElf.
std::string getVersion() const
Returns the version string of this symbol.
virtual SgAsmGenericSectionPtrList getRemapSections(SgAsmGenericHeader *) override
Returns mappable sections in a particular order.
void addVersion(const VersionedSymbol &vsymbol)
Add an additional versioned symbol to this entry.
void dump(FILE *, const char *prefix, ssize_t idx) const
Dump info like for SgAsm* objects.
void buildMasterSymbolTable(SgAsmInterpretation *)
Builds the master symbol table.
ConflictResolution
Describes how conflicts are resolved when mapping a section.
Base class for loading a static or dynamic object.
virtual std::string get_string(bool escape=false) const
Property: String value.
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...
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.
SymbolMap symbols_
Symbol table for an entire interpretation.
SgAsmElfSymverDefinedEntry * versionDef() const
Property: Version definition of this symbol.
std::string getVersionedName() const
Returns the full, versionioned name of this symbol.
Symbol from .dynsym combined with additional information.
The ELF symbol version table.
bool isBaseDefinition() const
Returns tru if this symbol is a base definition.
Represents an interpretation of a binary container.
std::string getName() const
Returns the name of this symbol.
void dump(FILE *, const char *prefix) const
Print info about this symbol map entry.
void print(std::ostream &) const
Print used by operator<<.
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.
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 * getSymbol() const
Returns the ELF symbol from the base version.
virtual bool canLoad(SgAsmGenericHeader *) const override
Capability query.
void fixupApplySymbolCopy(SgAsmElfRelocEntry *, const SymverResolver &, const MemoryMap::Ptr &)
Copies symbol memory to the relocation target.
bool isLocal() const
Returns true if this symbol is visible only locally.
void dump(FILE *, const char *prefix, ssize_t idx) const
Print some info about the resolver.