mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-24 08:18:33 +00:00
llvm-readobj: call exit(1) on error.
llvm-readobj exists for testing llvm. We can safely stop the program the first time we know the input in corrupted. This is in preparation for making it handle a few more broken files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242656 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -375,8 +375,7 @@ void MachODumper::printSections(const MachOObjectFile *Obj) {
|
||||
DataRefImpl DR = Section.getRawDataRefImpl();
|
||||
|
||||
StringRef Name;
|
||||
if (error(Section.getName(Name)))
|
||||
Name = "";
|
||||
error(Section.getName(Name));
|
||||
|
||||
ArrayRef<char> RawName = Obj->getSectionRawName(DR);
|
||||
StringRef SegmentName = Obj->getSectionFinalSegmentName(DR);
|
||||
@@ -419,8 +418,7 @@ void MachODumper::printSections(const MachOObjectFile *Obj) {
|
||||
bool IsBSS = Section.isBSS();
|
||||
if (!IsBSS) {
|
||||
StringRef Data;
|
||||
if (error(Section.getContents(Data)))
|
||||
break;
|
||||
error(Section.getContents(Data));
|
||||
|
||||
W.printBinaryBlock("SectionData", Data);
|
||||
}
|
||||
@@ -434,8 +432,7 @@ void MachODumper::printRelocations() {
|
||||
std::error_code EC;
|
||||
for (const SectionRef &Section : Obj->sections()) {
|
||||
StringRef Name;
|
||||
if (error(Section.getName(Name)))
|
||||
continue;
|
||||
error(Section.getName(Name));
|
||||
|
||||
bool PrintedGroup = false;
|
||||
for (const RelocationRef &Reloc : Section.relocations()) {
|
||||
@@ -475,15 +472,13 @@ void MachODumper::printRelocation(const MachOObjectFile *Obj,
|
||||
symbol_iterator Symbol = Reloc.getSymbol();
|
||||
if (Symbol != Obj->symbol_end()) {
|
||||
ErrorOr<StringRef> TargetNameOrErr = Symbol->getName();
|
||||
if (error(TargetNameOrErr.getError()))
|
||||
return;
|
||||
error(TargetNameOrErr.getError());
|
||||
TargetName = *TargetNameOrErr;
|
||||
}
|
||||
} else if (!IsScattered) {
|
||||
section_iterator SecI = Obj->getRelocationSection(DR);
|
||||
if (SecI != Obj->section_end()) {
|
||||
if (error(SecI->getName(TargetName)))
|
||||
return;
|
||||
error(SecI->getName(TargetName));
|
||||
}
|
||||
}
|
||||
if (TargetName.empty())
|
||||
@@ -548,7 +543,8 @@ void MachODumper::printSymbol(const SymbolRef &Symbol) {
|
||||
|
||||
StringRef SectionName = "";
|
||||
section_iterator SecI(Obj->section_begin());
|
||||
if (!error(Symbol.getSection(SecI)) && SecI != Obj->section_end())
|
||||
error(Symbol.getSection(SecI));
|
||||
if (SecI != Obj->section_end())
|
||||
error(SecI->getName(SectionName));
|
||||
|
||||
DictScope D(W, "Symbol");
|
||||
|
||||
Reference in New Issue
Block a user