|
@@ -632,12 +632,14 @@ void COFFDumper::printFileHeaders() {
|
|
// Print PE header. This header does not exist if this is an object file and
|
|
// Print PE header. This header does not exist if this is an object file and
|
|
// not an executable.
|
|
// not an executable.
|
|
const pe32_header *PEHeader = nullptr;
|
|
const pe32_header *PEHeader = nullptr;
|
|
- error(Obj->getPE32Header(PEHeader));
|
|
|
|
|
|
+ if (std::error_code EC = Obj->getPE32Header(PEHeader))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
if (PEHeader)
|
|
if (PEHeader)
|
|
printPEHeader<pe32_header>(PEHeader);
|
|
printPEHeader<pe32_header>(PEHeader);
|
|
|
|
|
|
const pe32plus_header *PEPlusHeader = nullptr;
|
|
const pe32plus_header *PEPlusHeader = nullptr;
|
|
- error(Obj->getPE32PlusHeader(PEPlusHeader));
|
|
|
|
|
|
+ if (std::error_code EC = Obj->getPE32PlusHeader(PEPlusHeader))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
if (PEPlusHeader)
|
|
if (PEPlusHeader)
|
|
printPEHeader<pe32plus_header>(PEPlusHeader);
|
|
printPEHeader<pe32plus_header>(PEPlusHeader);
|
|
|
|
|
|
@@ -732,7 +734,9 @@ void COFFDumper::printCOFFDebugDirectory() {
|
|
if (D.Type == COFF::IMAGE_DEBUG_TYPE_CODEVIEW) {
|
|
if (D.Type == COFF::IMAGE_DEBUG_TYPE_CODEVIEW) {
|
|
const codeview::DebugInfo *DebugInfo;
|
|
const codeview::DebugInfo *DebugInfo;
|
|
StringRef PDBFileName;
|
|
StringRef PDBFileName;
|
|
- error(Obj->getDebugPDBInfo(&D, DebugInfo, PDBFileName));
|
|
|
|
|
|
+ if (std::error_code EC = Obj->getDebugPDBInfo(&D, DebugInfo, PDBFileName))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+
|
|
DictScope PDBScope(W, "PDBInfo");
|
|
DictScope PDBScope(W, "PDBInfo");
|
|
W.printHex("PDBSignature", DebugInfo->Signature.CVSignature);
|
|
W.printHex("PDBSignature", DebugInfo->Signature.CVSignature);
|
|
if (DebugInfo->Signature.CVSignature == OMF::Signature::PDB70) {
|
|
if (DebugInfo->Signature.CVSignature == OMF::Signature::PDB70) {
|
|
@@ -744,8 +748,9 @@ void COFFDumper::printCOFFDebugDirectory() {
|
|
// FIXME: Type values of 12 and 13 are commonly observed but are not in
|
|
// FIXME: Type values of 12 and 13 are commonly observed but are not in
|
|
// the documented type enum. Figure out what they mean.
|
|
// the documented type enum. Figure out what they mean.
|
|
ArrayRef<uint8_t> RawData;
|
|
ArrayRef<uint8_t> RawData;
|
|
- error(
|
|
|
|
- Obj->getRvaAndSizeAsBytes(D.AddressOfRawData, D.SizeOfData, RawData));
|
|
|
|
|
|
+ if (std::error_code EC = Obj->getRvaAndSizeAsBytes(D.AddressOfRawData,
|
|
|
|
+ D.SizeOfData, RawData))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printBinaryBlock("RawData", RawData);
|
|
W.printBinaryBlock("RawData", RawData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -754,8 +759,11 @@ void COFFDumper::printCOFFDebugDirectory() {
|
|
void COFFDumper::printRVATable(uint64_t TableVA, uint64_t Count,
|
|
void COFFDumper::printRVATable(uint64_t TableVA, uint64_t Count,
|
|
uint64_t EntrySize, PrintExtraCB PrintExtra) {
|
|
uint64_t EntrySize, PrintExtraCB PrintExtra) {
|
|
uintptr_t TableStart, TableEnd;
|
|
uintptr_t TableStart, TableEnd;
|
|
- error(Obj->getVaPtr(TableVA, TableStart));
|
|
|
|
- error(Obj->getVaPtr(TableVA + Count * EntrySize - 1, TableEnd));
|
|
|
|
|
|
+ if (std::error_code EC = Obj->getVaPtr(TableVA, TableStart))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+ if (std::error_code EC =
|
|
|
|
+ Obj->getVaPtr(TableVA + Count * EntrySize - 1, TableEnd))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
TableEnd++;
|
|
TableEnd++;
|
|
for (uintptr_t I = TableStart; I < TableEnd; I += EntrySize) {
|
|
for (uintptr_t I = TableStart; I < TableEnd; I += EntrySize) {
|
|
uint32_t RVA = *reinterpret_cast<const ulittle32_t *>(I);
|
|
uint32_t RVA = *reinterpret_cast<const ulittle32_t *>(I);
|
|
@@ -959,7 +967,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|
|
|
|
|
W.printHex("Magic", Magic);
|
|
W.printHex("Magic", Magic);
|
|
if (Magic != COFF::DEBUG_SECTION_MAGIC)
|
|
if (Magic != COFF::DEBUG_SECTION_MAGIC)
|
|
- return error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
|
|
|
|
BinaryStreamReader FSReader(Data, support::little);
|
|
BinaryStreamReader FSReader(Data, support::little);
|
|
initializeFileAndStringTables(FSReader);
|
|
initializeFileAndStringTables(FSReader);
|
|
@@ -985,7 +993,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|
|
|
|
|
// Get the contents of the subsection.
|
|
// Get the contents of the subsection.
|
|
if (SubSectionSize > Data.size())
|
|
if (SubSectionSize > Data.size())
|
|
- return error(object_error::parse_failed);
|
|
|
|
|
|
+ return reportError(object_error::parse_failed, Obj->getFileName());
|
|
StringRef Contents = Data.substr(0, SubSectionSize);
|
|
StringRef Contents = Data.substr(0, SubSectionSize);
|
|
|
|
|
|
// Add SubSectionSize to the current offset and align that offset to find
|
|
// Add SubSectionSize to the current offset and align that offset to find
|
|
@@ -994,7 +1002,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|
size_t NextOffset = SectionOffset + SubSectionSize;
|
|
size_t NextOffset = SectionOffset + SubSectionSize;
|
|
NextOffset = alignTo(NextOffset, 4);
|
|
NextOffset = alignTo(NextOffset, 4);
|
|
if (NextOffset > SectionContents.size())
|
|
if (NextOffset > SectionContents.size())
|
|
- return error(object_error::parse_failed);
|
|
|
|
|
|
+ return reportError(object_error::parse_failed, Obj->getFileName());
|
|
Data = SectionContents.drop_front(NextOffset);
|
|
Data = SectionContents.drop_front(NextOffset);
|
|
|
|
|
|
// Optionally print the subsection bytes in case our parsing gets confused
|
|
// Optionally print the subsection bytes in case our parsing gets confused
|
|
@@ -1024,17 +1032,19 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|
if (SubSectionSize < 12) {
|
|
if (SubSectionSize < 12) {
|
|
// There should be at least three words to store two function
|
|
// There should be at least three words to store two function
|
|
// relocations and size of the code.
|
|
// relocations and size of the code.
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
StringRef LinkageName;
|
|
StringRef LinkageName;
|
|
- error(resolveSymbolName(Obj->getCOFFSection(Section), SectionOffset,
|
|
|
|
- LinkageName));
|
|
|
|
|
|
+ if (std::error_code EC = resolveSymbolName(Obj->getCOFFSection(Section),
|
|
|
|
+ SectionOffset, LinkageName))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+
|
|
W.printString("LinkageName", LinkageName);
|
|
W.printString("LinkageName", LinkageName);
|
|
if (FunctionLineTables.count(LinkageName) != 0) {
|
|
if (FunctionLineTables.count(LinkageName) != 0) {
|
|
// Saw debug info for this function already?
|
|
// Saw debug info for this function already?
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1051,8 +1061,10 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|
reportError(std::move(E), Obj->getFileName());
|
|
reportError(std::move(E), Obj->getFileName());
|
|
|
|
|
|
StringRef LinkageName;
|
|
StringRef LinkageName;
|
|
- error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
|
|
|
|
- FrameData.getRelocPtr(), LinkageName));
|
|
|
|
|
|
+ if (std::error_code EC =
|
|
|
|
+ resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
|
|
|
|
+ FrameData.getRelocPtr(), LinkageName))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printString("LinkageName", LinkageName);
|
|
W.printString("LinkageName", LinkageName);
|
|
|
|
|
|
// To find the active frame description, search this array for the
|
|
// To find the active frame description, search this array for the
|
|
@@ -1122,7 +1134,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|
uint32_t ColumnIndex = 0;
|
|
uint32_t ColumnIndex = 0;
|
|
for (const auto &Line : Entry.LineNumbers) {
|
|
for (const auto &Line : Entry.LineNumbers) {
|
|
if (Line.Offset >= LineInfo.header()->CodeSize) {
|
|
if (Line.Offset >= LineInfo.header()->CodeSize) {
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1159,10 +1171,9 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
|
|
CompilationCPUType, opts::CodeViewSubsectionBytes);
|
|
CompilationCPUType, opts::CodeViewSubsectionBytes);
|
|
CVSymbolArray Symbols;
|
|
CVSymbolArray Symbols;
|
|
BinaryStreamReader Reader(BinaryData, llvm::support::little);
|
|
BinaryStreamReader Reader(BinaryData, llvm::support::little);
|
|
- if (auto EC = Reader.readArray(Symbols, Reader.getLength())) {
|
|
|
|
- consumeError(std::move(EC));
|
|
|
|
|
|
+ if (Error E = Reader.readArray(Symbols, Reader.getLength())) {
|
|
W.flush();
|
|
W.flush();
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(std::move(E), Obj->getFileName());
|
|
}
|
|
}
|
|
|
|
|
|
if (Error E = CVSD.dump(Symbols)) {
|
|
if (Error E = CVSD.dump(Symbols)) {
|
|
@@ -1218,13 +1229,13 @@ void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
|
|
StringRef COFFDumper::getFileNameForFileOffset(uint32_t FileOffset) {
|
|
StringRef COFFDumper::getFileNameForFileOffset(uint32_t FileOffset) {
|
|
// The file checksum subsection should precede all references to it.
|
|
// The file checksum subsection should precede all references to it.
|
|
if (!CVFileChecksumTable.valid() || !CVStringTable.valid())
|
|
if (!CVFileChecksumTable.valid() || !CVStringTable.valid())
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
|
|
|
|
auto Iter = CVFileChecksumTable.getArray().at(FileOffset);
|
|
auto Iter = CVFileChecksumTable.getArray().at(FileOffset);
|
|
|
|
|
|
// Check if the file checksum table offset is valid.
|
|
// Check if the file checksum table offset is valid.
|
|
if (Iter == CVFileChecksumTable.end())
|
|
if (Iter == CVFileChecksumTable.end())
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
|
|
|
|
return unwrapOrError(Obj->getFileName(),
|
|
return unwrapOrError(Obj->getFileName(),
|
|
CVStringTable.getString(Iter->FileNameOffset));
|
|
CVStringTable.getString(Iter->FileNameOffset));
|
|
@@ -1248,14 +1259,14 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
|
|
reportError(std::move(E), Obj->getFileName());
|
|
reportError(std::move(E), Obj->getFileName());
|
|
|
|
|
|
if (Magic != 4)
|
|
if (Magic != 4)
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
|
|
|
|
CVTypeArray Types;
|
|
CVTypeArray Types;
|
|
BinaryStreamReader Reader(Data, llvm::support::little);
|
|
BinaryStreamReader Reader(Data, llvm::support::little);
|
|
if (auto EC = Reader.readArray(Types, Reader.getLength())) {
|
|
if (auto EC = Reader.readArray(Types, Reader.getLength())) {
|
|
consumeError(std::move(EC));
|
|
consumeError(std::move(EC));
|
|
W.flush();
|
|
W.flush();
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
}
|
|
}
|
|
SmallVector<TypeIndex, 128> SourceToDest;
|
|
SmallVector<TypeIndex, 128> SourceToDest;
|
|
Optional<uint32_t> PCHSignature;
|
|
Optional<uint32_t> PCHSignature;
|
|
@@ -1290,7 +1301,7 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
|
|
|
|
|
|
W.printHex("Magic", Magic);
|
|
W.printHex("Magic", Magic);
|
|
if (Magic != COFF::DEBUG_SECTION_MAGIC)
|
|
if (Magic != COFF::DEBUG_SECTION_MAGIC)
|
|
- return error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
|
|
|
|
Types.reset(Data, 100);
|
|
Types.reset(Data, 100);
|
|
|
|
|
|
@@ -1386,7 +1397,9 @@ void COFFDumper::printRelocation(const SectionRef &Section,
|
|
int64_t SymbolIndex = -1;
|
|
int64_t SymbolIndex = -1;
|
|
if (Symbol != Obj->symbol_end()) {
|
|
if (Symbol != Obj->symbol_end()) {
|
|
Expected<StringRef> SymbolNameOrErr = Symbol->getName();
|
|
Expected<StringRef> SymbolNameOrErr = Symbol->getName();
|
|
- error(errorToErrorCode(SymbolNameOrErr.takeError()));
|
|
|
|
|
|
+ if (!SymbolNameOrErr)
|
|
|
|
+ reportError(SymbolNameOrErr.takeError(), Obj->getFileName());
|
|
|
|
+
|
|
SymbolName = *SymbolNameOrErr;
|
|
SymbolName = *SymbolNameOrErr;
|
|
SymbolIndex = Obj->getSymbolIndex(Obj->getCOFFSymbol(*Symbol));
|
|
SymbolIndex = Obj->getSymbolIndex(Obj->getCOFFSymbol(*Symbol));
|
|
}
|
|
}
|
|
@@ -1463,7 +1476,8 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
for (uint8_t I = 0; I < Symbol.getNumberOfAuxSymbols(); ++I) {
|
|
for (uint8_t I = 0; I < Symbol.getNumberOfAuxSymbols(); ++I) {
|
|
if (Symbol.isFunctionDefinition()) {
|
|
if (Symbol.isFunctionDefinition()) {
|
|
const coff_aux_function_definition *Aux;
|
|
const coff_aux_function_definition *Aux;
|
|
- error(getSymbolAuxData(Obj, Symbol, I, Aux));
|
|
|
|
|
|
+ if (std::error_code EC = getSymbolAuxData(Obj, Symbol, I, Aux))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
|
|
DictScope AS(W, "AuxFunctionDef");
|
|
DictScope AS(W, "AuxFunctionDef");
|
|
W.printNumber("TagIndex", Aux->TagIndex);
|
|
W.printNumber("TagIndex", Aux->TagIndex);
|
|
@@ -1473,14 +1487,15 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
|
|
|
|
} else if (Symbol.isAnyUndefined()) {
|
|
} else if (Symbol.isAnyUndefined()) {
|
|
const coff_aux_weak_external *Aux;
|
|
const coff_aux_weak_external *Aux;
|
|
- error(getSymbolAuxData(Obj, Symbol, I, Aux));
|
|
|
|
|
|
+ if (std::error_code EC = getSymbolAuxData(Obj, Symbol, I, Aux))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
|
|
Expected<COFFSymbolRef> Linked = Obj->getSymbol(Aux->TagIndex);
|
|
Expected<COFFSymbolRef> Linked = Obj->getSymbol(Aux->TagIndex);
|
|
StringRef LinkedName;
|
|
StringRef LinkedName;
|
|
std::error_code EC = errorToErrorCode(Linked.takeError());
|
|
std::error_code EC = errorToErrorCode(Linked.takeError());
|
|
if (EC || (EC = Obj->getSymbolName(*Linked, LinkedName))) {
|
|
if (EC || (EC = Obj->getSymbolName(*Linked, LinkedName))) {
|
|
LinkedName = "";
|
|
LinkedName = "";
|
|
- error(EC);
|
|
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
}
|
|
}
|
|
|
|
|
|
DictScope AS(W, "AuxWeakExternal");
|
|
DictScope AS(W, "AuxWeakExternal");
|
|
@@ -1490,8 +1505,8 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
|
|
|
|
} else if (Symbol.isFileRecord()) {
|
|
} else if (Symbol.isFileRecord()) {
|
|
const char *FileName;
|
|
const char *FileName;
|
|
- error(getSymbolAuxData(Obj, Symbol, I, FileName));
|
|
|
|
-
|
|
|
|
|
|
+ if (std::error_code EC = getSymbolAuxData(Obj, Symbol, I, FileName))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
DictScope AS(W, "AuxFileRecord");
|
|
DictScope AS(W, "AuxFileRecord");
|
|
|
|
|
|
StringRef Name(FileName, Symbol.getNumberOfAuxSymbols() *
|
|
StringRef Name(FileName, Symbol.getNumberOfAuxSymbols() *
|
|
@@ -1500,7 +1515,8 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
break;
|
|
break;
|
|
} else if (Symbol.isSectionDefinition()) {
|
|
} else if (Symbol.isSectionDefinition()) {
|
|
const coff_aux_section_definition *Aux;
|
|
const coff_aux_section_definition *Aux;
|
|
- error(getSymbolAuxData(Obj, Symbol, I, Aux));
|
|
|
|
|
|
+ if (std::error_code EC = getSymbolAuxData(Obj, Symbol, I, Aux))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
|
|
int32_t AuxNumber = Aux->getNumber(Symbol.isBigObj());
|
|
int32_t AuxNumber = Aux->getNumber(Symbol.isBigObj());
|
|
|
|
|
|
@@ -1517,7 +1533,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
const coff_section *Assoc;
|
|
const coff_section *Assoc;
|
|
StringRef AssocName = "";
|
|
StringRef AssocName = "";
|
|
if (std::error_code EC = Obj->getSection(AuxNumber, Assoc))
|
|
if (std::error_code EC = Obj->getSection(AuxNumber, Assoc))
|
|
- error(EC);
|
|
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
Expected<StringRef> Res = getSectionName(Obj, AuxNumber, Assoc);
|
|
Expected<StringRef> Res = getSectionName(Obj, AuxNumber, Assoc);
|
|
if (!Res)
|
|
if (!Res)
|
|
reportError(Res.takeError(), Obj->getFileName());
|
|
reportError(Res.takeError(), Obj->getFileName());
|
|
@@ -1527,7 +1543,8 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
}
|
|
}
|
|
} else if (Symbol.isCLRToken()) {
|
|
} else if (Symbol.isCLRToken()) {
|
|
const coff_aux_clr_token *Aux;
|
|
const coff_aux_clr_token *Aux;
|
|
- error(getSymbolAuxData(Obj, Symbol, I, Aux));
|
|
|
|
|
|
+ if (std::error_code EC = getSymbolAuxData(Obj, Symbol, I, Aux))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
|
|
Expected<COFFSymbolRef> ReferredSym =
|
|
Expected<COFFSymbolRef> ReferredSym =
|
|
Obj->getSymbol(Aux->SymbolTableIndex);
|
|
Obj->getSymbol(Aux->SymbolTableIndex);
|
|
@@ -1535,7 +1552,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|
std::error_code EC = errorToErrorCode(ReferredSym.takeError());
|
|
std::error_code EC = errorToErrorCode(ReferredSym.takeError());
|
|
if (EC || (EC = Obj->getSymbolName(*ReferredSym, ReferredName))) {
|
|
if (EC || (EC = Obj->getSymbolName(*ReferredSym, ReferredName))) {
|
|
ReferredName = "";
|
|
ReferredName = "";
|
|
- error(EC);
|
|
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
}
|
|
}
|
|
|
|
|
|
DictScope AS(W, "AuxCLRToken");
|
|
DictScope AS(W, "AuxCLRToken");
|
|
@@ -1602,9 +1619,11 @@ void COFFDumper::printImportedSymbols(
|
|
iterator_range<imported_symbol_iterator> Range) {
|
|
iterator_range<imported_symbol_iterator> Range) {
|
|
for (const ImportedSymbolRef &I : Range) {
|
|
for (const ImportedSymbolRef &I : Range) {
|
|
StringRef Sym;
|
|
StringRef Sym;
|
|
- error(I.getSymbolName(Sym));
|
|
|
|
|
|
+ if (std::error_code EC = I.getSymbolName(Sym))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
uint16_t Ordinal;
|
|
uint16_t Ordinal;
|
|
- error(I.getOrdinal(Ordinal));
|
|
|
|
|
|
+ if (std::error_code EC = I.getOrdinal(Ordinal))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printNumber("Symbol", Sym, Ordinal);
|
|
W.printNumber("Symbol", Sym, Ordinal);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1616,12 +1635,17 @@ void COFFDumper::printDelayImportedSymbols(
|
|
for (const ImportedSymbolRef &S : Range) {
|
|
for (const ImportedSymbolRef &S : Range) {
|
|
DictScope Import(W, "Import");
|
|
DictScope Import(W, "Import");
|
|
StringRef Sym;
|
|
StringRef Sym;
|
|
- error(S.getSymbolName(Sym));
|
|
|
|
|
|
+ if (std::error_code EC = S.getSymbolName(Sym))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+
|
|
uint16_t Ordinal;
|
|
uint16_t Ordinal;
|
|
- error(S.getOrdinal(Ordinal));
|
|
|
|
|
|
+ if (std::error_code EC = S.getOrdinal(Ordinal))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printNumber("Symbol", Sym, Ordinal);
|
|
W.printNumber("Symbol", Sym, Ordinal);
|
|
|
|
+
|
|
uint64_t Addr;
|
|
uint64_t Addr;
|
|
- error(I.getImportAddress(Index++, Addr));
|
|
|
|
|
|
+ if (std::error_code EC = I.getImportAddress(Index++, Addr))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printHex("Address", Addr);
|
|
W.printHex("Address", Addr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1631,13 +1655,16 @@ void COFFDumper::printCOFFImports() {
|
|
for (const ImportDirectoryEntryRef &I : Obj->import_directories()) {
|
|
for (const ImportDirectoryEntryRef &I : Obj->import_directories()) {
|
|
DictScope Import(W, "Import");
|
|
DictScope Import(W, "Import");
|
|
StringRef Name;
|
|
StringRef Name;
|
|
- error(I.getName(Name));
|
|
|
|
|
|
+ if (std::error_code EC = I.getName(Name))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printString("Name", Name);
|
|
W.printString("Name", Name);
|
|
uint32_t ILTAddr;
|
|
uint32_t ILTAddr;
|
|
- error(I.getImportLookupTableRVA(ILTAddr));
|
|
|
|
|
|
+ if (std::error_code EC = I.getImportLookupTableRVA(ILTAddr))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printHex("ImportLookupTableRVA", ILTAddr);
|
|
W.printHex("ImportLookupTableRVA", ILTAddr);
|
|
uint32_t IATAddr;
|
|
uint32_t IATAddr;
|
|
- error(I.getImportAddressTableRVA(IATAddr));
|
|
|
|
|
|
+ if (std::error_code EC = I.getImportAddressTableRVA(IATAddr))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printHex("ImportAddressTableRVA", IATAddr);
|
|
W.printHex("ImportAddressTableRVA", IATAddr);
|
|
// The import lookup table can be missing with certain older linkers, so
|
|
// The import lookup table can be missing with certain older linkers, so
|
|
// fall back to the import address table in that case.
|
|
// fall back to the import address table in that case.
|
|
@@ -1651,10 +1678,12 @@ void COFFDumper::printCOFFImports() {
|
|
for (const DelayImportDirectoryEntryRef &I : Obj->delay_import_directories()) {
|
|
for (const DelayImportDirectoryEntryRef &I : Obj->delay_import_directories()) {
|
|
DictScope Import(W, "DelayImport");
|
|
DictScope Import(W, "DelayImport");
|
|
StringRef Name;
|
|
StringRef Name;
|
|
- error(I.getName(Name));
|
|
|
|
|
|
+ if (std::error_code EC = I.getName(Name))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printString("Name", Name);
|
|
W.printString("Name", Name);
|
|
const delay_import_directory_table_entry *Table;
|
|
const delay_import_directory_table_entry *Table;
|
|
- error(I.getDelayImportTable(Table));
|
|
|
|
|
|
+ if (std::error_code EC = I.getDelayImportTable(Table))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
W.printHex("Attributes", Table->Attributes);
|
|
W.printHex("Attributes", Table->Attributes);
|
|
W.printHex("ModuleHandle", Table->ModuleHandle);
|
|
W.printHex("ModuleHandle", Table->ModuleHandle);
|
|
W.printHex("ImportAddressTable", Table->DelayImportAddressTable);
|
|
W.printHex("ImportAddressTable", Table->DelayImportAddressTable);
|
|
@@ -1672,9 +1701,12 @@ void COFFDumper::printCOFFExports() {
|
|
StringRef Name;
|
|
StringRef Name;
|
|
uint32_t Ordinal, RVA;
|
|
uint32_t Ordinal, RVA;
|
|
|
|
|
|
- error(E.getSymbolName(Name));
|
|
|
|
- error(E.getOrdinal(Ordinal));
|
|
|
|
- error(E.getExportRVA(RVA));
|
|
|
|
|
|
+ if (std::error_code EC = E.getSymbolName(Name))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+ if (std::error_code EC = E.getOrdinal(Ordinal))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+ if (std::error_code EC = E.getExportRVA(RVA))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
|
|
W.printNumber("Ordinal", Ordinal);
|
|
W.printNumber("Ordinal", Ordinal);
|
|
W.printString("Name", Name);
|
|
W.printString("Name", Name);
|
|
@@ -1712,8 +1744,10 @@ void COFFDumper::printCOFFBaseReloc() {
|
|
for (const BaseRelocRef &I : Obj->base_relocs()) {
|
|
for (const BaseRelocRef &I : Obj->base_relocs()) {
|
|
uint8_t Type;
|
|
uint8_t Type;
|
|
uint32_t RVA;
|
|
uint32_t RVA;
|
|
- error(I.getRVA(RVA));
|
|
|
|
- error(I.getType(Type));
|
|
|
|
|
|
+ if (std::error_code EC = I.getRVA(RVA))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
|
|
+ if (std::error_code EC = I.getType(Type))
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
DictScope Import(W, "Entry");
|
|
DictScope Import(W, "Entry");
|
|
W.printString("Type", getBaseRelocTypeName(Type));
|
|
W.printString("Type", getBaseRelocTypeName(Type));
|
|
W.printHex("Address", RVA);
|
|
W.printHex("Address", RVA);
|
|
@@ -1797,7 +1831,7 @@ void COFFDumper::printResourceDirectoryTable(
|
|
}
|
|
}
|
|
std::string EntryNameString;
|
|
std::string EntryNameString;
|
|
if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
|
|
if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
|
|
- error(object_error::parse_failed);
|
|
|
|
|
|
+ reportError(object_error::parse_failed, Obj->getFileName());
|
|
OS << ": ";
|
|
OS << ": ";
|
|
OS << EntryNameString;
|
|
OS << EntryNameString;
|
|
} else {
|
|
} else {
|
|
@@ -1905,14 +1939,14 @@ void COFFDumper::printAddrsig() {
|
|
const char *Err;
|
|
const char *Err;
|
|
uint64_t SymIndex = decodeULEB128(Cur, &Size, End, &Err);
|
|
uint64_t SymIndex = decodeULEB128(Cur, &Size, End, &Err);
|
|
if (Err)
|
|
if (Err)
|
|
- reportError(Err);
|
|
|
|
|
|
+ reportError(createError(Err), Obj->getFileName());
|
|
|
|
|
|
Expected<COFFSymbolRef> Sym = Obj->getSymbol(SymIndex);
|
|
Expected<COFFSymbolRef> Sym = Obj->getSymbol(SymIndex);
|
|
StringRef SymName;
|
|
StringRef SymName;
|
|
std::error_code EC = errorToErrorCode(Sym.takeError());
|
|
std::error_code EC = errorToErrorCode(Sym.takeError());
|
|
if (EC || (EC = Obj->getSymbolName(*Sym, SymName))) {
|
|
if (EC || (EC = Obj->getSymbolName(*Sym, SymName))) {
|
|
SymName = "";
|
|
SymName = "";
|
|
- error(EC);
|
|
|
|
|
|
+ reportError(EC, Obj->getFileName());
|
|
}
|
|
}
|
|
|
|
|
|
W.printNumber("Sym", SymName, SymIndex);
|
|
W.printNumber("Sym", SymName, SymIndex);
|