20 #include "pedigree/kernel/linker/SymbolTable.h" 21 #include "pedigree/kernel/LockGuard.h" 22 #include "pedigree/kernel/utilities/Iterator.h" 25 #define RAII_LOCK LockGuard<Mutex> guard(m_Lock) 31 : m_LocalSymbols(), m_GlobalSymbols(), m_WeakSymbols(),
32 m_pOriginatingElf(pElf)
46 m_LocalSymbols = newSymtab.m_LocalSymbols;
47 m_GlobalSymbols = newSymtab.m_GlobalSymbols;
48 m_WeakSymbols = newSymtab.m_WeakSymbols;
56 doInsert(name, binding, pParent, value);
74 size_t numGlobal,
size_t numWeak,
Elf *localElf,
size_t numLocal)
77 tree->reserve(numLocal);
80 tree->reserve(numGlobal);
83 tree->reserve(numWeak);
87 size_t numGlobal,
size_t numWeak,
Elf *localElf,
size_t numLocal)
90 tree->reserve(tree->count() + numGlobal);
93 tree->reserve(tree->count() + numWeak);
96 tree->reserve(tree->count() + numLocal);
112 auto tree =
getOrInsertTree(symbol->getParent(), symbol->getBinding());
113 tree->
insert(name, symbol);
116 void SymbolTable::eraseByElf(
Elf *pParent)
121 m_LocalSymbols.
remove(pParent);
122 m_GlobalSymbols.
remove(pParent);
123 m_WeakSymbols.
remove(pParent);
134 uintptr_t lookupResult = 0;
143 if (result.hasValue())
145 lookupResult = result.value()->getValue();
154 it != m_GlobalSymbols.
end();
158 if (result.hasValue())
160 lookupResult = result.value()->getValue();
170 it != m_WeakSymbols.
end();
174 if (result.hasValue())
176 lookupResult = result.value()->getValue();
197 tree = &m_LocalSymbols;
200 tree = &m_GlobalSymbols;
203 tree = &m_WeakSymbols;
210 return symbolTree.get();
214 auto result = newTree.get();
215 tree->
insert(p, pedigree_std::move(newTree));
const E & lookupRef(const K &key, const E &failed=E()) const
uintptr_t EXPORTED_PUBLIC lookup(const HashedStringView &name, Elf *pElf, Policy policy=LocalFirst, Binding *pBinding=0)
void preallocateAdditional(size_t numGlobal, size_t numWeak, Elf *localElf, size_t numLocal)
symbolTree_t * getOrInsertTree(Elf *, Binding table=Local)
void insert(const K &key, const E &value)
void insert(const String &name, Binding binding, Elf *pParent, uintptr_t value)
bool insert(const K &k, const V &v)
void insertShared(const String &name, SharedPointer< Symbol > &symbol)
LookupResult lookup(const K &k) const
void copyTable(Elf *pNewElf, const SymbolTable &newSymtab)
void remove(const K &key)
void insertMultiple(SymbolTable *pOther, const String &name, Binding binding, Elf *pParent, uintptr_t value)
An iterator applicable for many data structures.
SharedPointer< Symbol > doInsert(const String &name, Binding binding, Elf *pParent, uintptr_t value)
void preallocate(size_t numGlobal, size_t numWeak, Elf *localElf, size_t numLocal)
static SharedPointer< T > allocate(Args...)