[llvm] r221870 - Object, COFF: getRelocationSymbol shouldn't assert
David Majnemer
david.majnemer at gmail.com
Wed Nov 12 23:42:11 PST 2014
Author: majnemer
Date: Thu Nov 13 01:42:11 2014
New Revision: 221870
URL: http://llvm.org/viewvc/llvm-project?rev=221870&view=rev
Log:
Object, COFF: getRelocationSymbol shouldn't assert
lib/Object is supposed to be robust to malformed object files. Don't
assert if we don't have a symbol table. I'll try to come up with a test
case later.
Modified:
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=221870&r1=221869&r2=221870&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Thu Nov 13 01:42:11 2014
@@ -996,7 +996,7 @@ symbol_iterator COFFObjectFile::getReloc
else if (SymbolTable32)
Ref.p = reinterpret_cast<uintptr_t>(SymbolTable32 + R->SymbolTableIndex);
else
- llvm_unreachable("no symbol table pointer!");
+ return symbol_end();
return symbol_iterator(SymbolRef(Ref, this));
}
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=221870&r1=221869&r2=221870&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Thu Nov 13 01:42:11 2014
@@ -800,7 +800,7 @@ void COFFDumper::printRelocation(const S
if (error(Reloc.getTypeName(RelocName)))
return;
symbol_iterator Symbol = Reloc.getSymbol();
- if (error(Symbol->getName(SymbolName)))
+ if (Symbol != Obj->symbol_end() && error(Symbol->getName(SymbolName)))
return;
if (error(Section.getContents(Contents)))
return;
@@ -809,12 +809,12 @@ void COFFDumper::printRelocation(const S
DictScope Group(W, "Relocation");
W.printHex("Offset", Offset);
W.printNumber("Type", RelocName, RelocType);
- W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-");
+ W.printString("Symbol", SymbolName.empty() ? "-" : SymbolName);
} else {
raw_ostream& OS = W.startLine();
OS << W.hex(Offset)
<< " " << RelocName
- << " " << (SymbolName.size() > 0 ? SymbolName : "-")
+ << " " << (SymbolName.empty() ? "-" : SymbolName)
<< "\n";
}
}
More information about the llvm-commits
mailing list