[llvm] r194415 - Fixing a problem with iterator validity in RuntimeDyldImpl::resolveExternalSymbols
Andrew Kaylor
andrew.kaylor at intel.com
Mon Nov 11 11:55:10 PST 2013
Author: akaylor
Date: Mon Nov 11 13:55:10 2013
New Revision: 194415
URL: http://llvm.org/viewvc/llvm-project?rev=194415&view=rev
Log:
Fixing a problem with iterator validity in RuntimeDyldImpl::resolveExternalSymbols
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=194415&r1=194414&r2=194415&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Nov 11 13:55:10 2013
@@ -494,10 +494,10 @@ void RuntimeDyldImpl::resolveExternalSym
StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin();
StringRef Name = i->first();
- RelocationList &Relocs = i->second;
if (Name.size() == 0) {
// This is an absolute symbol, use an address of zero.
DEBUG(dbgs() << "Resolving absolute relocations." << "\n");
+ RelocationList &Relocs = i->second;
resolveRelocationList(Relocs, 0);
} else {
uint64_t Addr = 0;
@@ -506,6 +506,13 @@ void RuntimeDyldImpl::resolveExternalSym
// This is an external symbol, try to get its address from
// MemoryManager.
Addr = MemMgr->getSymbolAddress(Name.data());
+ // The call to getSymbolAddress may have caused additional modules to
+ // be loaded, which may have added new entries to the
+ // ExternalSymbolRelocations map. Consquently, we need to update our
+ // iterator. This is also why retrieval of the relocation list
+ // associated with this symbol is deferred until below this point.
+ // New entries may have been added to the relocation list.
+ i = ExternalSymbolRelocations.find(Name);
} else {
// We found the symbol in our global table. It was probably in a
// Module that we loaded previously.
@@ -522,10 +529,13 @@ void RuntimeDyldImpl::resolveExternalSym
DEBUG(dbgs() << "Resolving relocations Name: " << Name
<< "\t" << format("0x%lx", Addr)
<< "\n");
+ // This list may have been updated when we called getSymbolAddress, so
+ // don't change this code to get the list earlier.
+ RelocationList &Relocs = i->second;
resolveRelocationList(Relocs, Addr);
}
- ExternalSymbolRelocations.erase(i->first());
+ ExternalSymbolRelocations.erase(i);
}
}
More information about the llvm-commits
mailing list