mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Adding multiple module support for MCJIT.
Tests to follow. PIC with small code model and EH frame handling will not work with multiple modules. There are also some rough edges to be smoothed out for remote target support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191722 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -49,6 +49,7 @@ void RuntimeDyldImpl::resolveRelocations() {
|
||||
<< "\t" << format("%p", (uint8_t *)Addr)
|
||||
<< "\n");
|
||||
resolveRelocationList(Relocations[i], Addr);
|
||||
Relocations.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,31 +465,42 @@ void RuntimeDyldImpl::resolveRelocationList(const RelocationList &Relocs,
|
||||
}
|
||||
|
||||
void RuntimeDyldImpl::resolveExternalSymbols() {
|
||||
StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin(),
|
||||
e = ExternalSymbolRelocations.end();
|
||||
for (; i != e; i++) {
|
||||
while(!ExternalSymbolRelocations.empty()) {
|
||||
StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin();
|
||||
|
||||
StringRef Name = i->first();
|
||||
RelocationList &Relocs = i->second;
|
||||
SymbolTableMap::const_iterator Loc = GlobalSymbolTable.find(Name);
|
||||
if (Loc == GlobalSymbolTable.end()) {
|
||||
if (Name.size() == 0) {
|
||||
// This is an absolute symbol, use an address of zero.
|
||||
DEBUG(dbgs() << "Resolving absolute relocations." << "\n");
|
||||
resolveRelocationList(Relocs, 0);
|
||||
} else {
|
||||
// This is an external symbol, try to get its address from
|
||||
// MemoryManager.
|
||||
uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(),
|
||||
true);
|
||||
updateGOTEntries(Name, (uint64_t)Addr);
|
||||
DEBUG(dbgs() << "Resolving relocations Name: " << Name
|
||||
<< "\t" << format("%p", Addr)
|
||||
<< "\n");
|
||||
resolveRelocationList(Relocs, (uintptr_t)Addr);
|
||||
}
|
||||
if (Name.size() == 0) {
|
||||
// This is an absolute symbol, use an address of zero.
|
||||
DEBUG(dbgs() << "Resolving absolute relocations." << "\n");
|
||||
resolveRelocationList(Relocs, 0);
|
||||
} else {
|
||||
report_fatal_error("Expected external symbol");
|
||||
uint64_t Addr = 0;
|
||||
SymbolTableMap::const_iterator Loc = GlobalSymbolTable.find(Name);
|
||||
if (Loc == GlobalSymbolTable.end()) {
|
||||
// This is an external symbol, try to get its address from
|
||||
// MemoryManager.
|
||||
Addr = MemMgr->getSymbolAddress(Name.data());
|
||||
} else {
|
||||
// We found the symbol in our global table. It was probably in a
|
||||
// Module that we loaded previously.
|
||||
SymbolLoc SymLoc = GlobalSymbolTable.lookup(Name);
|
||||
Addr = getSectionLoadAddress(SymLoc.first) + SymLoc.second;
|
||||
}
|
||||
|
||||
// FIXME: Implement error handling that doesn't kill the host program!
|
||||
if (!Addr)
|
||||
report_fatal_error("Program used external function '" + Name +
|
||||
"' which could not be resolved!");
|
||||
|
||||
updateGOTEntries(Name, Addr);
|
||||
DEBUG(dbgs() << "Resolving relocations Name: " << Name
|
||||
<< "\t" << format("0x%lx", Addr)
|
||||
<< "\n");
|
||||
resolveRelocationList(Relocs, Addr);
|
||||
}
|
||||
|
||||
ExternalSymbolRelocations.erase(i->first());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,10 +562,14 @@ ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {
|
||||
}
|
||||
|
||||
void *RuntimeDyld::getSymbolAddress(StringRef Name) {
|
||||
if (!Dyld)
|
||||
return NULL;
|
||||
return Dyld->getSymbolAddress(Name);
|
||||
}
|
||||
|
||||
uint64_t RuntimeDyld::getSymbolLoadAddress(StringRef Name) {
|
||||
if (!Dyld)
|
||||
return 0;
|
||||
return Dyld->getSymbolLoadAddress(Name);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user