mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-18 18:32:32 +00:00
Fixing a problem with iterator validity in RuntimeDyldImpl::resolveExternalSymbols
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194415 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
07a5d3dc3d
commit
559d409633
@ -494,10 +494,10 @@ void RuntimeDyldImpl::resolveExternalSymbols() {
|
|||||||
StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin();
|
StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin();
|
||||||
|
|
||||||
StringRef Name = i->first();
|
StringRef Name = i->first();
|
||||||
RelocationList &Relocs = i->second;
|
|
||||||
if (Name.size() == 0) {
|
if (Name.size() == 0) {
|
||||||
// This is an absolute symbol, use an address of zero.
|
// This is an absolute symbol, use an address of zero.
|
||||||
DEBUG(dbgs() << "Resolving absolute relocations." << "\n");
|
DEBUG(dbgs() << "Resolving absolute relocations." << "\n");
|
||||||
|
RelocationList &Relocs = i->second;
|
||||||
resolveRelocationList(Relocs, 0);
|
resolveRelocationList(Relocs, 0);
|
||||||
} else {
|
} else {
|
||||||
uint64_t Addr = 0;
|
uint64_t Addr = 0;
|
||||||
@ -506,6 +506,13 @@ void RuntimeDyldImpl::resolveExternalSymbols() {
|
|||||||
// This is an external symbol, try to get its address from
|
// This is an external symbol, try to get its address from
|
||||||
// MemoryManager.
|
// MemoryManager.
|
||||||
Addr = MemMgr->getSymbolAddress(Name.data());
|
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 {
|
} else {
|
||||||
// We found the symbol in our global table. It was probably in a
|
// We found the symbol in our global table. It was probably in a
|
||||||
// Module that we loaded previously.
|
// Module that we loaded previously.
|
||||||
@ -522,10 +529,13 @@ void RuntimeDyldImpl::resolveExternalSymbols() {
|
|||||||
DEBUG(dbgs() << "Resolving relocations Name: " << Name
|
DEBUG(dbgs() << "Resolving relocations Name: " << Name
|
||||||
<< "\t" << format("0x%lx", Addr)
|
<< "\t" << format("0x%lx", Addr)
|
||||||
<< "\n");
|
<< "\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);
|
resolveRelocationList(Relocs, Addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalSymbolRelocations.erase(i->first());
|
ExternalSymbolRelocations.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user