1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

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.

llvm-svn: 221870
This commit is contained in:
David Majnemer 2014-11-13 07:42:11 +00:00
parent c6acbb53c8
commit 854aeb4e3e
2 changed files with 4 additions and 4 deletions

View File

@ -996,7 +996,7 @@ symbol_iterator COFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
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));
}

View File

@ -800,7 +800,7 @@ void COFFDumper::printRelocation(const SectionRef &Section,
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 SectionRef &Section,
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";
}
}