diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-01-16 22:26:39 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-01-16 22:26:39 +0000 |
commit | eff0a40d7e5a440b470f8f16459c8aa1ad8c1345 (patch) | |
tree | b96f833f38527be3ec29a9dc29b2f026d3480502 /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | |
parent | d5e4edbfbfe3a36a5733fbef65416ee0fee869c2 (diff) | |
download | bcm5719-llvm-eff0a40d7e5a440b470f8f16459c8aa1ad8c1345.tar.gz bcm5719-llvm-eff0a40d7e5a440b470f8f16459c8aa1ad8c1345.zip |
MCJIT support for non-function sections.
Move to a by-section allocation and relocation scheme. This allows
better support for sections which do not contain externally visible
symbols.
Flesh out the relocation address vs. local storage address separation a
bit more as well. Remote process JITs use this to tell the relocation
resolution code where the code will live when it executes.
The startFunctionBody/endFunctionBody interfaces to the JIT and the
memory manager are deprecated. They'll stick around for as long as the
old JIT does, but the MCJIT doesn't use them anymore.
llvm-svn: 148258
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index b017ebb2dcb..18827978d9a 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -25,6 +25,7 @@ namespace llvm { void RuntimeDyldImpl::extractFunction(StringRef Name, uint8_t *StartAddress, uint8_t *EndAddress) { + // FIXME: DEPRECATED in favor of by-section allocation. // Allocate memory for the function via the memory manager. uintptr_t Size = EndAddress - StartAddress + 1; uintptr_t AllocSize = Size; @@ -35,21 +36,22 @@ void RuntimeDyldImpl::extractFunction(StringRef Name, uint8_t *StartAddress, memcpy(Mem, StartAddress, Size); MemMgr->endFunctionBody(Name.data(), Mem, Mem + Size); // Remember where we put it. - Functions[Name] = sys::MemoryBlock(Mem, Size); + unsigned SectionID = Sections.size(); + Sections.push_back(sys::MemoryBlock(Mem, Size)); + // Default the assigned address for this symbol to wherever this // allocated it. - SymbolTable[Name] = Mem; + SymbolTable[Name] = SymbolLoc(SectionID, 0); DEBUG(dbgs() << " allocated to [" << Mem << ", " << Mem + Size << "]\n"); } // Resolve the relocations for all symbols we currently know about. void RuntimeDyldImpl::resolveRelocations() { - // Just iterate over the symbols in our symbol table and assign their - // addresses. - StringMap<uint8_t*>::iterator i = SymbolTable.begin(); - StringMap<uint8_t*>::iterator e = SymbolTable.end(); - for (;i != e; ++i) - reassignSymbolAddress(i->getKey(), i->getValue()); + // Just iterate over the sections we have and resolve all the relocations + // in them. Gross overkill, but it gets the job done. + for (int i = 0, e = Sections.size(); i != e; ++i) { + reassignSectionAddress(i, SectionLoadAddress[i]); + } } //===----------------------------------------------------------------------===// @@ -109,8 +111,9 @@ void RuntimeDyld::resolveRelocations() { Dyld->resolveRelocations(); } -void RuntimeDyld::reassignSymbolAddress(StringRef Name, uint8_t *Addr) { - Dyld->reassignSymbolAddress(Name, Addr); +void RuntimeDyld::reassignSectionAddress(unsigned SectionID, + uint64_t Addr) { + Dyld->reassignSectionAddress(SectionID, Addr); } StringRef RuntimeDyld::getErrorString() { |