[llvm] r183288 - Handle (at least don't crash on) relocations with no symbols.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jun 4 19:55:01 PDT 2013
Author: rafael
Date: Tue Jun 4 21:55:01 2013
New Revision: 183288
URL: http://llvm.org/viewvc/llvm-project?rev=183288&view=rev
Log:
Handle (at least don't crash on) relocations with no symbols.
Should fix the MCJIT tests on PPC.
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=183288&r1=183287&r2=183288&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Tue Jun 4 21:55:01 2013
@@ -780,23 +780,28 @@ void RuntimeDyldELF::processRelocationRe
// Obtain the symbol name which is referenced in the relocation
StringRef TargetName;
- Symbol->getName(TargetName);
+ if (Symbol != Obj.end_symbols())
+ Symbol->getName(TargetName);
DEBUG(dbgs() << "\t\tRelType: " << RelType
<< " Addend: " << Addend
<< " TargetName: " << TargetName
<< "\n");
RelocationValueRef Value;
// First search for the symbol in the local symbol table
- SymbolTableMap::const_iterator lsi = Symbols.find(TargetName.data());
- SymbolRef::Type SymType;
- Symbol->getType(SymType);
+ SymbolTableMap::const_iterator lsi = Symbols.end();
+ SymbolRef::Type SymType = SymbolRef::ST_Unknown;
+ if (Symbol != Obj.end_symbols()) {
+ lsi = Symbols.find(TargetName.data());
+ Symbol->getType(SymType);
+ }
if (lsi != Symbols.end()) {
Value.SectionID = lsi->second.first;
Value.Addend = lsi->second.second + Addend;
} else {
// Search for the symbol in the global symbol table
- SymbolTableMap::const_iterator gsi =
- GlobalSymbolTable.find(TargetName.data());
+ SymbolTableMap::const_iterator gsi = GlobalSymbolTable.end();
+ if (Symbol != Obj.end_symbols())
+ gsi = GlobalSymbolTable.find(TargetName.data());
if (gsi != GlobalSymbolTable.end()) {
Value.SectionID = gsi->second.first;
Value.Addend = gsi->second.second + Addend;
More information about the llvm-commits
mailing list