1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[ExecutionEngine] Add a getSymbolTable method to RuntimeDyld.

This can be used to extract the symbol table from a RuntimeDyld instance prior
to disposing of it.

This patch also updates RTDyldObjectLinkingLayer to use the new method, rather
than requesting symbols one at a time via getSymbol.

llvm-svn: 327476
This commit is contained in:
Lang Hames 2018-03-14 06:25:07 +00:00
parent 4748ea7638
commit 738674c4c6
4 changed files with 34 additions and 6 deletions

View File

@ -133,7 +133,12 @@ private:
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> Info =
PFC->RTDyld->loadObject(*PFC->Obj.getBinary());
updateSymbolTable(*PFC->RTDyld);
// Copy the symbol table out of the RuntimeDyld instance.
{
auto SymTab = PFC->RTDyld->getSymbolTable();
for (auto &KV : SymTab)
SymbolTable[KV.first] = KV.second;
}
if (PFC->Parent.NotifyLoaded)
PFC->Parent.NotifyLoaded(PFC->K, *PFC->Obj.getBinary(), *Info);
@ -187,11 +192,6 @@ private:
}
}
void updateSymbolTable(const RuntimeDyld &RTDyld) {
for (auto &SymEntry : SymbolTable)
SymEntry.second = RTDyld.getSymbol(SymEntry.first());
}
// Contains the information needed prior to finalization: the object files,
// memory manager, resolver, and flags needed for RuntimeDyld.
struct PreFinalizeContents {

View File

@ -189,6 +189,13 @@ public:
/// This address is the one used for relocation.
JITEvaluatedSymbol getSymbol(StringRef Name) const;
/// Returns a copy of the symbol table. This can be used by on-finalized
/// callbacks to extract the symbol table before throwing away the
/// RuntimeDyld instance. Because the map keys (StringRefs) are backed by
/// strings inside the RuntimeDyld instance, the map should be processed
/// before the RuntimeDyld instance is discarded.
std::map<StringRef, JITEvaluatedSymbol> getSymbolTable() const;
/// Resolve the relocations for all symbols we currently know about.
void resolveRelocations();

View File

@ -1198,6 +1198,12 @@ JITEvaluatedSymbol RuntimeDyld::getSymbol(StringRef Name) const {
return Dyld->getSymbol(Name);
}
std::map<StringRef, JITEvaluatedSymbol> RuntimeDyld::getSymbolTable() const {
if (!Dyld)
return {};
return Dyld->getSymbolTable();
}
void RuntimeDyld::resolveRelocations() { Dyld->resolveRelocations(); }
void RuntimeDyld::reassignSectionAddress(unsigned SectionID, uint64_t Addr) {

View File

@ -519,6 +519,21 @@ public:
return JITEvaluatedSymbol(TargetAddr, SymEntry.getFlags());
}
std::map<StringRef, JITEvaluatedSymbol> getSymbolTable() const {
std::map<StringRef, JITEvaluatedSymbol> Result;
for (auto &KV : GlobalSymbolTable) {
auto SectionID = KV.second.getSectionID();
uint64_t SectionAddr = 0;
if (SectionID != AbsoluteSymbolSection)
SectionAddr = getSectionLoadAddress(SectionID);
Result[KV.first()] =
JITEvaluatedSymbol(SectionAddr + KV.second.getOffset(), KV.second.getFlags());
}
return Result;
}
void resolveRelocations();
void reassignSectionAddress(unsigned SectionID, uint64_t Addr);