|
The Pedigree Project 0.1
|
#include <SymbolTable.h>
Collaboration diagram for SymbolTable: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) |
| bool | hasPreallocated () const |
| void | eraseByElf (Elf *pParent) |
| uintptr_t EXPORTED_PUBLIC | lookup (const HashedStringView &name, Elf *pElf, Policy policy=LocalFirst, Binding *pBinding=0) |
| uintptr_t | lookupOwned (const HashedStringView &name, Elf *owner) |
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 |
| bool | m_bPreallocated |
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.
|
private |
Definition at line 140 of file SymbolTable.h.
|
private |
Definition at line 139 of file SymbolTable.h.
| enum SymbolTable::Binding |
Binding types, to define how symbols interact.
Definition at line 46 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 50 of file SymbolTable.h.
| SymbolTable::SymbolTable | ( | Elf * | pElf | ) |
Class constructor - creates an empty table.
Definition at line 26 of file SymbolTable.cc.
| SymbolTable::~SymbolTable | ( | ) |
Destructor - destroys all information.
Definition at line 33 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 35 of file SymbolTable.cc.
Referenced by Elf::Elf().
Here is the caller graph for this function:
|
private |
Insert doer.
Definition at line 97 of file SymbolTable.cc.
References insertShared().
Referenced by insert(), and insertMultiple().
Here is the caller graph for this function:| void SymbolTable::eraseByElf | ( | Elf * | pParent | ) |
Definition at line 111 of file SymbolTable.cc.
|
private |
Get or insert a Symbol tree.
Definition at line 186 of file SymbolTable.cc.
References SharedPointer< T >::allocate(), Tree< K, E >::insert(), and Tree< K, E >::lookupRef().
Referenced by insertShared(), preallocate(), and preallocateAdditional().
Here is the caller graph for this function:| bool SymbolTable::hasPreallocated | ( | ) | const |
Has a preallocation already taken place on this SymbolTable?
Definition at line 92 of file SymbolTable.cc.
Referenced by Elf::preallocateSymbols().
Here is the caller graph for this function:Insert a symbol into the table.
Definition at line 45 of file SymbolTable.cc.
References doInsert().
Referenced by Elf::allocate(), KernelElf::initialise(), Elf::loadModule(), and Elf::populateSymbolTable().
Here is the caller graph for this function:| 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 51 of file SymbolTable.cc.
References doInsert(), and insertShared().
Referenced by Elf::allocate().
Here is the caller graph for this function:
|
private |
Insert the given shared symbol.
Definition at line 106 of file SymbolTable.cc.
References getOrInsertTree().
Referenced by doInsert(), and insertMultiple().
Here is the caller graph for this function:| 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 120 of file SymbolTable.cc.
References Tree< K, E >::begin(), Tree< K, E >::end(), Tree< K, E >::lookupRef(), and NotOriginatingElf.
Referenced by Elf::applyRelocation(), KernelElf::globalLookupSymbol(), Elf::lookupDynamicSymbolAddress(), Elf::lookupSymbol(), and DynamicLinker::resolve().
Here is the caller graph for this function:| uintptr_t SymbolTable::lookupOwned | ( | const HashedStringView & | name, |
| Elf * | owner | ||
| ) |
Looks up only exports owned by the specified ELF, without allocating.
Definition at line 170 of file SymbolTable.cc.
Referenced by KernelElf::resolveRuntimeImport().
Here is the caller graph for this function:
|
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 61 of file SymbolTable.cc.
References getOrInsertTree().
Referenced by KernelElf::initialise(), and Elf::preallocateSymbols().
Here is the caller graph for this function:| void SymbolTable::preallocateAdditional | ( | size_t | numGlobal, |
| size_t | numWeak, | ||
| Elf * | localElf, | ||
| size_t | numLocal | ||
| ) |
Preallocate additional symbols to the existing count.
Definition at line 76 of file SymbolTable.cc.
References getOrInsertTree().
Referenced by Elf::preallocateSymbols().
Here is the caller graph for this function:
|
private |
Definition at line 153 of file SymbolTable.h.
|
private |
Definition at line 146 of file SymbolTable.h.
|
private |
Definition at line 145 of file SymbolTable.h.
|
mutableprivate |
Definition at line 151 of file SymbolTable.h.
|
private |
Definition at line 149 of file SymbolTable.h.
|
private |
Definition at line 147 of file SymbolTable.h.