diff options
author | Eli Bendersky <eli.bendersky@intel.com> | 2012-05-01 06:58:59 +0000 |
---|---|---|
committer | Eli Bendersky <eli.bendersky@intel.com> | 2012-05-01 06:58:59 +0000 |
commit | d98c9e918c9750d965c1efe9efcc9e13feacbe13 (patch) | |
tree | d85e0b1338e2838386364bc04162ac44393267b2 /lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | |
parent | e499cdf10c157d447393708b3a28497e42b1b555 (diff) |
RuntimeDyld code cleanup:
- There's no point having a different type for the local and global symbol
tables.
- Renamed SymbolTable to GlobalSymbolTable to clarify the intention
- Improved const correctness where relevant
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r-- | lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index ce45404051..7266f69190 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -75,11 +75,15 @@ bool RuntimeDyldImpl::loadObject(const MemoryBuffer *InputBuffer) { Arch = (Triple::ArchType)obj->getArch(); - LocalSymbolMap LocalSymbols; // Functions and data symbols from the - // object file. - ObjSectionToIDMap LocalSections; // Used sections from the object file - CommonSymbolMap CommonSymbols; // Common symbols requiring allocation - uint64_t CommonSize = 0; + // Symbols found in this object + StringMap<SymbolLoc> LocalSymbols; + // Used sections from the object file + ObjSectionToIDMap LocalSections; + + // Common symbols requiring allocation, and the total size required to + // allocate all common symbols. + CommonSymbolMap CommonSymbols; + uint64_t CommonSize = 0; error_code err; // Parse symbols @@ -128,7 +132,7 @@ bool RuntimeDyldImpl::loadObject(const MemoryBuffer *InputBuffer) { << " Offset: " << format("%p", SectOffset)); bool isGlobal = flags & SymbolRef::SF_Global; if (isGlobal) - SymbolTable[Name] = SymbolLoc(SectionID, SectOffset); + GlobalSymbolTable[Name] = SymbolLoc(SectionID, SectOffset); } } DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name << "\n"); @@ -181,7 +185,7 @@ bool RuntimeDyldImpl::loadObject(const MemoryBuffer *InputBuffer) { unsigned RuntimeDyldImpl::emitCommonSymbols(ObjectImage &Obj, const CommonSymbolMap &Map, uint64_t TotalSize, - LocalSymbolMap &LocalSymbols) { + SymbolTableMap &Symbols) { // Allocate memory for the section unsigned SectionID = Sections.size(); uint8_t *Addr = MemMgr->allocateDataSection(TotalSize, sizeof(void*), @@ -204,7 +208,7 @@ unsigned RuntimeDyldImpl::emitCommonSymbols(ObjectImage &Obj, StringRef Name; it->first.getName(Name); Obj.updateSymbolAddress(it->first, (uint64_t)Addr); - LocalSymbols[Name.data()] = SymbolLoc(SectionID, Offset); + Symbols[Name.data()] = SymbolLoc(SectionID, Offset); Offset += Size; Addr += Size; } @@ -330,8 +334,9 @@ void RuntimeDyldImpl::addRelocation(const RelocationValueRef &Value, // ExternalSymbolRelocations. RelocationEntry RE(SectionID, Offset, RelType, Value.Addend); - StringMap<SymbolLoc>::const_iterator Loc = SymbolTable.find(Value.SymbolName); - if (Loc == SymbolTable.end()) { + SymbolTableMap::const_iterator Loc = + GlobalSymbolTable.find(Value.SymbolName); + if (Loc == GlobalSymbolTable.end()) { ExternalSymbolRelocations[Value.SymbolName].push_back(RE); } else { RE.Addend += Loc->second.second; @@ -400,8 +405,8 @@ void RuntimeDyldImpl::resolveExternalSymbols() { for (; i != e; i++) { StringRef Name = i->first(); RelocationList &Relocs = i->second; - StringMap<SymbolLoc>::const_iterator Loc = SymbolTable.find(Name); - if (Loc == SymbolTable.end()) { + SymbolTableMap::const_iterator Loc = GlobalSymbolTable.find(Name); + if (Loc == GlobalSymbolTable.end()) { // This is an external symbol, try to get it address from // MemoryManager. uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(), |