The Pedigree Project
0.1
|
#include <SymbolTable.h>
Classes | |
class | Symbol |
Public Types | |
enum | Binding { Local, Global, Weak } |
enum | Policy { LocalFirst, NotOriginatingElf } |
Public Member Functions | |
SymbolTable (Elf *pElf) | |
~SymbolTable () | |
SymbolTable (const SymbolTable &symtab) | |
void | copyTable (Elf *pNewElf, const SymbolTable &newSymtab) |
void | insert (const String &name, Binding binding, Elf *pParent, uintptr_t value) |
void | insertMultiple (SymbolTable *pOther, const String &name, Binding binding, Elf *pParent, uintptr_t value) |
void | preallocate (size_t numGlobal, size_t numWeak, Elf *localElf, size_t numLocal) |
void | preallocateAdditional (size_t numGlobal, size_t numWeak, Elf *localElf, size_t numLocal) |
void | eraseByElf (Elf *pParent) |
uintptr_t EXPORTED_PUBLIC | lookup (const HashedStringView &name, Elf *pElf, Policy policy=LocalFirst, Binding *pBinding=0) |
Private Types | |
typedef HashTable< String, SharedPointer< Symbol >, HashedStringView > | symbolTree_t |
typedef Tree< Elf *, SharedPointer< symbolTree_t > > | parentedSymbolTree_t |
Private Member Functions | |
SymbolTable & | operator= (const SymbolTable &) |
SharedPointer< Symbol > | doInsert (const String &name, Binding binding, Elf *pParent, uintptr_t value) |
void | insertShared (const String &name, SharedPointer< Symbol > &symbol) |
symbolTree_t * | getOrInsertTree (Elf *, Binding table=Local) |
Private Attributes | |
parentedSymbolTree_t | m_LocalSymbols |
parentedSymbolTree_t | m_GlobalSymbols |
parentedSymbolTree_t | m_WeakSymbols |
Elf * | m_pOriginatingElf |
Mutex | m_Lock |
This class allows quick access to symbol information held within ELF files. The lookup operation allows multiple policies to retrieve the wanted symbol.
Definition at line 43 of file SymbolTable.h.
enum SymbolTable::Binding |
Binding types, to define how symbols interact.
Definition at line 47 of file SymbolTable.h.
enum SymbolTable::Policy |
Lookup policies - given multiple definitions of a symbol, how do we determine the best response?
Definition at line 56 of file SymbolTable.h.
SymbolTable::SymbolTable | ( | Elf * | pElf | ) |
Class constructor - creates an empty table.
Definition at line 30 of file SymbolTable.cc.
SymbolTable::~SymbolTable | ( | ) |
Destructor - destroys all information.
Definition at line 36 of file SymbolTable.cc.
SymbolTable::SymbolTable | ( | const SymbolTable & | symtab | ) |
Copy constructor.
void SymbolTable::copyTable | ( | Elf * | pNewElf, |
const SymbolTable & | newSymtab | ||
) |
Copies the symbol table
Definition at line 40 of file SymbolTable.cc.
Referenced by Elf::Elf().
|
private |
Insert doer.
Definition at line 99 of file SymbolTable.cc.
References insertShared().
Referenced by insert(), and insertMultiple().
|
private |
Get or insert a Symbol tree.
Definition at line 188 of file SymbolTable.cc.
References SharedPointer< T >::allocate(), Tree< K, E >::insert(), and Tree< K, E >::lookupRef().
Referenced by insertShared(), preallocate(), and preallocateAdditional().
Insert a symbol into the table.
Definition at line 51 of file SymbolTable.cc.
References doInsert().
Referenced by Elf::allocate(), KernelElf::initialise(), Elf::loadModule(), and Elf::populateSymbolTable().
void SymbolTable::insertMultiple | ( | SymbolTable * | pOther, |
const String & | name, | ||
Binding | binding, | ||
Elf * | pParent, | ||
uintptr_t | value | ||
) |
Insert a symbol into two SymbolTables, using the memory once.
Definition at line 59 of file SymbolTable.cc.
References doInsert(), and insertShared().
Referenced by Elf::allocate().
|
private |
Insert the given shared symbol.
Definition at line 109 of file SymbolTable.cc.
References getOrInsertTree(), HashTable< K, V, SiblingK, InitialBuckets, QuadraticProbe, GrowthFactor >::insert(), and Tree< K, E >::remove().
Referenced by doInsert(), and insertMultiple().
uintptr_t SymbolTable::lookup | ( | const HashedStringView & | name, |
Elf * | pElf, | ||
Policy | policy = LocalFirst , |
||
Binding * | pBinding = 0 |
||
) |
Looks up a symbol in the table, optionally outputting the binding value.
If the policy is set as "LocalFirst" (the default), then Local and Global definitions from pElf are given priority.
If the policy is set as "NotOriginatingElf", no symbols in pElf will ever be matched, preferring those from other ELFs. This is used for R_COPY relocations.
Definition at line 126 of file SymbolTable.cc.
References Tree< K, E >::begin(), Tree< K, E >::end(), HashTable< K, V, SiblingK, InitialBuckets, QuadraticProbe, GrowthFactor >::lookup(), Tree< K, E >::lookupRef(), and NotOriginatingElf.
Referenced by Elf::applyRelocation(), KernelElf::globalLookupSymbol(), Elf::lookupDynamicSymbolAddress(), Elf::lookupSymbol(), and DynamicLinker::resolve().
|
private |
Copy constructor.
void SymbolTable::preallocate | ( | size_t | numGlobal, |
size_t | numWeak, | ||
Elf * | localElf, | ||
size_t | numLocal | ||
) |
Preallocate at least the minimum space for the given symbol tables.
Definition at line 73 of file SymbolTable.cc.
References getOrInsertTree().
Referenced by KernelElf::initialise(), and Elf::preallocateSymbols().
void SymbolTable::preallocateAdditional | ( | size_t | numGlobal, |
size_t | numWeak, | ||
Elf * | localElf, | ||
size_t | numLocal | ||
) |
Preallocate additional symbols to the existing count.
Definition at line 86 of file SymbolTable.cc.
References getOrInsertTree().
Referenced by Elf::preallocateSymbols().