mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-21 03:00:45 +00:00
[llvm-readobj] - Remove 'error(Error EC)' helper.
We do not need it. I replaced it with reportError(StringRef Input, Error Err). Differential revision: https://reviews.llvm.org/D66011 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368677 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9ca54d8f2f
commit
a5068cdcdc
@ -79,10 +79,10 @@ Sections:
|
|||||||
## that goes past the end of file.
|
## that goes past the end of file.
|
||||||
|
|
||||||
# RUN: yaml2obj --docnum=2 %s > %t2.so
|
# RUN: yaml2obj --docnum=2 %s > %t2.so
|
||||||
# RUN: not llvm-readelf --notes %t2.so 2>&1 | FileCheck %s --check-prefix=ERR1
|
# RUN: not llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1
|
||||||
# RUN: not llvm-readobj --notes %t2.so 2>&1 | FileCheck %s --check-prefix=ERR1
|
# RUN: not llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1
|
||||||
|
|
||||||
# ERR1: error: SHT_NOTE section [index 1] has invalid offset (0xffff0000) or size (0x0)
|
# ERR1: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset (0xffff0000) or size (0x0)
|
||||||
|
|
||||||
--- !ELF
|
--- !ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
@ -99,10 +99,10 @@ Sections:
|
|||||||
## that goes past the end of file.
|
## that goes past the end of file.
|
||||||
|
|
||||||
# RUN: yaml2obj --docnum=3 %s > %t3.so
|
# RUN: yaml2obj --docnum=3 %s > %t3.so
|
||||||
# RUN: not llvm-readelf --notes %t3.so 2>&1 | FileCheck %s --check-prefix=ERR2
|
# RUN: not llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2
|
||||||
# RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck %s --check-prefix=ERR2
|
# RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2
|
||||||
|
|
||||||
# ERR2: error: SHT_NOTE section [index 1] has invalid offset (0x180) or size (0xffff0000)
|
# ERR2: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset (0x180) or size (0xffff0000)
|
||||||
|
|
||||||
--- !ELF
|
--- !ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
@ -119,10 +119,10 @@ Sections:
|
|||||||
## goes past the end of file.
|
## goes past the end of file.
|
||||||
|
|
||||||
# RUN: yaml2obj --docnum=4 %s > %t4.so
|
# RUN: yaml2obj --docnum=4 %s > %t4.so
|
||||||
# RUN: not llvm-readelf --notes %t4.so 2>&1 | FileCheck %s --check-prefix=ERR3
|
# RUN: not llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3
|
||||||
# RUN: not llvm-readobj --notes %t4.so 2>&1 | FileCheck %s --check-prefix=ERR3
|
# RUN: not llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3
|
||||||
|
|
||||||
# ERR3: error: PT_NOTE header has invalid offset (0xffff0000) or size (0x0)
|
# ERR3: error: '[[FILE]]': PT_NOTE header has invalid offset (0xffff0000) or size (0x0)
|
||||||
|
|
||||||
--- !ELF
|
--- !ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
@ -143,10 +143,10 @@ ProgramHeaders:
|
|||||||
## goes past the end of file.
|
## goes past the end of file.
|
||||||
|
|
||||||
# RUN: yaml2obj --docnum=5 %s > %t5.so
|
# RUN: yaml2obj --docnum=5 %s > %t5.so
|
||||||
# RUN: not llvm-readelf --notes %t5.so 2>&1 | FileCheck %s --check-prefix=ERR4
|
# RUN: not llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4
|
||||||
# RUN: not llvm-readobj --notes %t5.so 2>&1 | FileCheck %s --check-prefix=ERR4
|
# RUN: not llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4
|
||||||
|
|
||||||
# ERR4: error: PT_NOTE header has invalid offset (0x1b8) or size (0xffff0000)
|
# ERR4: error: '[[FILE]]': PT_NOTE header has invalid offset (0x1b8) or size (0xffff0000)
|
||||||
|
|
||||||
--- !ELF
|
--- !ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
|
@ -370,7 +370,7 @@ PrinterContext<ET>::FunctionAtAddress(unsigned Section,
|
|||||||
return readobj_error::unknown_symbol;
|
return readobj_error::unknown_symbol;
|
||||||
auto StrTableOrErr = ELF->getStringTableForSymtab(*Symtab);
|
auto StrTableOrErr = ELF->getStringTableForSymtab(*Symtab);
|
||||||
if (!StrTableOrErr)
|
if (!StrTableOrErr)
|
||||||
error(StrTableOrErr.takeError());
|
reportError(StrTableOrErr.takeError(), FileName);
|
||||||
StringRef StrTable = *StrTableOrErr;
|
StringRef StrTable = *StrTableOrErr;
|
||||||
|
|
||||||
for (const Elf_Sym &Sym : unwrapOrError(FileName, ELF->symbols(Symtab)))
|
for (const Elf_Sym &Sym : unwrapOrError(FileName, ELF->symbols(Symtab)))
|
||||||
@ -405,7 +405,7 @@ PrinterContext<ET>::FindExceptionTable(unsigned IndexSectionIndex,
|
|||||||
|
|
||||||
auto SymTabOrErr = ELF->getSection(Sec.sh_link);
|
auto SymTabOrErr = ELF->getSection(Sec.sh_link);
|
||||||
if (!SymTabOrErr)
|
if (!SymTabOrErr)
|
||||||
error(SymTabOrErr.takeError());
|
reportError(SymTabOrErr.takeError(), FileName);
|
||||||
const Elf_Shdr *SymTab = *SymTabOrErr;
|
const Elf_Shdr *SymTab = *SymTabOrErr;
|
||||||
|
|
||||||
for (const Elf_Rel &R : unwrapOrError(FileName, ELF->rels(&Sec))) {
|
for (const Elf_Rel &R : unwrapOrError(FileName, ELF->rels(&Sec))) {
|
||||||
|
@ -912,26 +912,33 @@ void COFFDumper::initializeFileAndStringTables(BinaryStreamReader &Reader) {
|
|||||||
// The section consists of a number of subsection in the following format:
|
// The section consists of a number of subsection in the following format:
|
||||||
// |SubSectionType|SubSectionSize|Contents...|
|
// |SubSectionType|SubSectionSize|Contents...|
|
||||||
uint32_t SubType, SubSectionSize;
|
uint32_t SubType, SubSectionSize;
|
||||||
error(Reader.readInteger(SubType));
|
|
||||||
error(Reader.readInteger(SubSectionSize));
|
if (Error E = Reader.readInteger(SubType))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
if (Error E = Reader.readInteger(SubSectionSize))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
StringRef Contents;
|
StringRef Contents;
|
||||||
error(Reader.readFixedString(Contents, SubSectionSize));
|
if (Error E = Reader.readFixedString(Contents, SubSectionSize))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
BinaryStreamRef ST(Contents, support::little);
|
BinaryStreamRef ST(Contents, support::little);
|
||||||
switch (DebugSubsectionKind(SubType)) {
|
switch (DebugSubsectionKind(SubType)) {
|
||||||
case DebugSubsectionKind::FileChecksums:
|
case DebugSubsectionKind::FileChecksums:
|
||||||
error(CVFileChecksumTable.initialize(ST));
|
if (Error E = CVFileChecksumTable.initialize(ST))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
break;
|
break;
|
||||||
case DebugSubsectionKind::StringTable:
|
case DebugSubsectionKind::StringTable:
|
||||||
error(CVStringTable.initialize(ST));
|
if (Error E = CVStringTable.initialize(ST))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PaddedSize = alignTo(SubSectionSize, 4);
|
uint32_t PaddedSize = alignTo(SubSectionSize, 4);
|
||||||
error(Reader.skip(PaddedSize - SubSectionSize));
|
if (Error E = Reader.skip(PaddedSize - SubSectionSize))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,7 +956,9 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|||||||
W.printNumber("Section", SectionName, Obj->getSectionID(Section));
|
W.printNumber("Section", SectionName, Obj->getSectionID(Section));
|
||||||
|
|
||||||
uint32_t Magic;
|
uint32_t Magic;
|
||||||
error(consume(Data, Magic));
|
if (Error E = consume(Data, Magic))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
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);
|
return error(object_error::parse_failed);
|
||||||
@ -962,8 +971,10 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|||||||
// The section consists of a number of subsection in the following format:
|
// The section consists of a number of subsection in the following format:
|
||||||
// |SubSectionType|SubSectionSize|Contents...|
|
// |SubSectionType|SubSectionSize|Contents...|
|
||||||
uint32_t SubType, SubSectionSize;
|
uint32_t SubType, SubSectionSize;
|
||||||
error(consume(Data, SubType));
|
if (Error E = consume(Data, SubType))
|
||||||
error(consume(Data, SubSectionSize));
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
if (Error E = consume(Data, SubSectionSize))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
ListScope S(W, "Subsection");
|
ListScope S(W, "Subsection");
|
||||||
// Dump the subsection as normal even if the ignore bit is set.
|
// Dump the subsection as normal even if the ignore bit is set.
|
||||||
@ -1038,7 +1049,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|||||||
BinaryStreamReader SR(Contents, llvm::support::little);
|
BinaryStreamReader SR(Contents, llvm::support::little);
|
||||||
|
|
||||||
DebugFrameDataSubsectionRef FrameData;
|
DebugFrameDataSubsectionRef FrameData;
|
||||||
error(FrameData.initialize(SR));
|
if (Error E = FrameData.initialize(SR))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
StringRef LinkageName;
|
StringRef LinkageName;
|
||||||
error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
|
error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
|
||||||
@ -1100,7 +1112,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
|
|||||||
BinaryStreamReader Reader(FunctionLineTables[Name], support::little);
|
BinaryStreamReader Reader(FunctionLineTables[Name], support::little);
|
||||||
|
|
||||||
DebugLinesSubsectionRef LineInfo;
|
DebugLinesSubsectionRef LineInfo;
|
||||||
error(LineInfo.initialize(Reader));
|
if (Error E = LineInfo.initialize(Reader))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
W.printHex("Flags", LineInfo.header()->Flags);
|
W.printHex("Flags", LineInfo.header()->Flags);
|
||||||
W.printHex("CodeSize", LineInfo.header()->CodeSize);
|
W.printHex("CodeSize", LineInfo.header()->CodeSize);
|
||||||
@ -1154,9 +1167,9 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
|
|||||||
error(object_error::parse_failed);
|
error(object_error::parse_failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto EC = CVSD.dump(Symbols)) {
|
if (Error E = CVSD.dump(Symbols)) {
|
||||||
W.flush();
|
W.flush();
|
||||||
error(std::move(EC));
|
reportError(std::move(E), Obj->getFileName());
|
||||||
}
|
}
|
||||||
CompilationCPUType = CVSD.getCompilationCPUType();
|
CompilationCPUType = CVSD.getCompilationCPUType();
|
||||||
W.flush();
|
W.flush();
|
||||||
@ -1165,7 +1178,8 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
|
|||||||
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
|
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
|
||||||
BinaryStreamRef Stream(Subsection, llvm::support::little);
|
BinaryStreamRef Stream(Subsection, llvm::support::little);
|
||||||
DebugChecksumsSubsectionRef Checksums;
|
DebugChecksumsSubsectionRef Checksums;
|
||||||
error(Checksums.initialize(Stream));
|
if (Error E = Checksums.initialize(Stream))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
for (auto &FC : Checksums) {
|
for (auto &FC : Checksums) {
|
||||||
DictScope S(W, "FileChecksum");
|
DictScope S(W, "FileChecksum");
|
||||||
@ -1184,7 +1198,8 @@ void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
|
|||||||
void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
|
void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
|
||||||
BinaryStreamReader SR(Subsection, llvm::support::little);
|
BinaryStreamReader SR(Subsection, llvm::support::little);
|
||||||
DebugInlineeLinesSubsectionRef Lines;
|
DebugInlineeLinesSubsectionRef Lines;
|
||||||
error(Lines.initialize(SR));
|
if (Error E = Lines.initialize(SR))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
for (auto &Line : Lines) {
|
for (auto &Line : Lines) {
|
||||||
DictScope S(W, "InlineeSourceLine");
|
DictScope S(W, "InlineeSourceLine");
|
||||||
@ -1232,7 +1247,9 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
|
|||||||
if (SectionName == ".debug$T") {
|
if (SectionName == ".debug$T") {
|
||||||
StringRef Data = unwrapOrError(Obj->getFileName(), S.getContents());
|
StringRef Data = unwrapOrError(Obj->getFileName(), S.getContents());
|
||||||
uint32_t Magic;
|
uint32_t Magic;
|
||||||
error(consume(Data, Magic));
|
if (Error E = consume(Data, Magic))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
if (Magic != 4)
|
if (Magic != 4)
|
||||||
error(object_error::parse_failed);
|
error(object_error::parse_failed);
|
||||||
|
|
||||||
@ -1248,14 +1265,14 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
|
|||||||
if (GHash) {
|
if (GHash) {
|
||||||
std::vector<GloballyHashedType> Hashes =
|
std::vector<GloballyHashedType> Hashes =
|
||||||
GloballyHashedType::hashTypes(Types);
|
GloballyHashedType::hashTypes(Types);
|
||||||
if (auto EC =
|
if (Error E =
|
||||||
mergeTypeAndIdRecords(GlobalCVIDs, GlobalCVTypes, SourceToDest,
|
mergeTypeAndIdRecords(GlobalCVIDs, GlobalCVTypes, SourceToDest,
|
||||||
Types, Hashes, PCHSignature))
|
Types, Hashes, PCHSignature))
|
||||||
return error(std::move(EC));
|
return reportError(std::move(E), Obj->getFileName());
|
||||||
} else {
|
} else {
|
||||||
if (auto EC = mergeTypeAndIdRecords(CVIDs, CVTypes, SourceToDest, Types,
|
if (Error E = mergeTypeAndIdRecords(CVIDs, CVTypes, SourceToDest, Types,
|
||||||
PCHSignature))
|
PCHSignature))
|
||||||
return error(std::move(EC));
|
return reportError(std::move(E), Obj->getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1271,7 +1288,9 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
|
|||||||
W.printBinaryBlock("Data", Data);
|
W.printBinaryBlock("Data", Data);
|
||||||
|
|
||||||
uint32_t Magic;
|
uint32_t Magic;
|
||||||
error(consume(Data, Magic));
|
if (Error E = consume(Data, Magic))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
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);
|
return error(object_error::parse_failed);
|
||||||
@ -1279,7 +1298,9 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
|
|||||||
Types.reset(Data, 100);
|
Types.reset(Data, 100);
|
||||||
|
|
||||||
TypeDumpVisitor TDV(Types, &W, opts::CodeViewSubsectionBytes);
|
TypeDumpVisitor TDV(Types, &W, opts::CodeViewSubsectionBytes);
|
||||||
error(codeview::visitTypeStream(Types, TDV));
|
if (Error E = codeview::visitTypeStream(Types, TDV))
|
||||||
|
reportError(std::move(E), Obj->getFileName());
|
||||||
|
|
||||||
W.flush();
|
W.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1504,7 +1525,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
|||||||
error(EC);
|
error(EC);
|
||||||
Expected<StringRef> Res = getSectionName(Obj, AuxNumber, Assoc);
|
Expected<StringRef> Res = getSectionName(Obj, AuxNumber, Assoc);
|
||||||
if (!Res)
|
if (!Res)
|
||||||
error(Res.takeError());
|
reportError(Res.takeError(), Obj->getFileName());
|
||||||
AssocName = *Res;
|
AssocName = *Res;
|
||||||
|
|
||||||
W.printNumber("AssocSection", AssocName, AuxNumber);
|
W.printNumber("AssocSection", AssocName, AuxNumber);
|
||||||
@ -1906,7 +1927,8 @@ void llvm::dumpCodeViewMergedTypes(ScopedPrinter &Writer,
|
|||||||
{
|
{
|
||||||
ListScope S(Writer, "MergedTypeStream");
|
ListScope S(Writer, "MergedTypeStream");
|
||||||
TypeDumpVisitor TDV(TpiTypes, &Writer, opts::CodeViewSubsectionBytes);
|
TypeDumpVisitor TDV(TpiTypes, &Writer, opts::CodeViewSubsectionBytes);
|
||||||
error(codeview::visitTypeStream(TpiTypes, TDV));
|
if (Error Err = codeview::visitTypeStream(TpiTypes, TDV))
|
||||||
|
reportError(std::move(Err), "<?>");
|
||||||
Writer.flush();
|
Writer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1917,7 +1939,8 @@ void llvm::dumpCodeViewMergedTypes(ScopedPrinter &Writer,
|
|||||||
ListScope S(Writer, "MergedIDStream");
|
ListScope S(Writer, "MergedIDStream");
|
||||||
TypeDumpVisitor TDV(TpiTypes, &Writer, opts::CodeViewSubsectionBytes);
|
TypeDumpVisitor TDV(TpiTypes, &Writer, opts::CodeViewSubsectionBytes);
|
||||||
TDV.setIpiTypes(IpiTypes);
|
TDV.setIpiTypes(IpiTypes);
|
||||||
error(codeview::visitTypeStream(IpiTypes, TDV));
|
if (Error Err = codeview::visitTypeStream(IpiTypes, TDV))
|
||||||
|
reportError(std::move(Err), "<?>");
|
||||||
Writer.flush();
|
Writer.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4417,7 +4417,7 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
|
|||||||
for (const auto &Note : Obj->notes(P, Err))
|
for (const auto &Note : Obj->notes(P, Err))
|
||||||
ProcessNote(Note);
|
ProcessNote(Note);
|
||||||
if (Err)
|
if (Err)
|
||||||
error(std::move(Err));
|
reportError(std::move(Err), this->FileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const auto &S :
|
for (const auto &S :
|
||||||
@ -4429,7 +4429,7 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
|
|||||||
for (const auto &Note : Obj->notes(S, Err))
|
for (const auto &Note : Obj->notes(S, Err))
|
||||||
ProcessNote(Note);
|
ProcessNote(Note);
|
||||||
if (Err)
|
if (Err)
|
||||||
error(std::move(Err));
|
reportError(std::move(Err), this->FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4483,10 +4483,10 @@ void DumpStyle<ELFT>::printFunctionStackSize(
|
|||||||
// integer.
|
// integer.
|
||||||
if (*Offset == PrevOffset)
|
if (*Offset == PrevOffset)
|
||||||
reportError(
|
reportError(
|
||||||
FileStr,
|
|
||||||
createStringError(object_error::parse_failed,
|
createStringError(object_error::parse_failed,
|
||||||
"could not extract a valid stack size in section %s",
|
"could not extract a valid stack size in section %s",
|
||||||
SectionName.data()));
|
SectionName.data()),
|
||||||
|
FileStr);
|
||||||
|
|
||||||
printStackSizeEntry(StackSize, FuncName);
|
printStackSizeEntry(StackSize, FuncName);
|
||||||
}
|
}
|
||||||
@ -4545,11 +4545,12 @@ void DumpStyle<ELFT>::printStackSize(const ELFObjectFile<ELFT> *Obj,
|
|||||||
|
|
||||||
uint64_t Offset = Reloc.getOffset();
|
uint64_t Offset = Reloc.getOffset();
|
||||||
if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1))
|
if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1))
|
||||||
reportError(FileStr, createStringError(
|
reportError(
|
||||||
object_error::parse_failed,
|
createStringError(object_error::parse_failed,
|
||||||
"found invalid relocation offset into section %s "
|
"found invalid relocation offset into section %s "
|
||||||
"while trying to extract a stack size entry",
|
"while trying to extract a stack size entry",
|
||||||
StackSizeSectionName.data()));
|
StackSizeSectionName.data()),
|
||||||
|
FileStr);
|
||||||
|
|
||||||
uint64_t Addend = Data.getAddress(&Offset);
|
uint64_t Addend = Data.getAddress(&Offset);
|
||||||
uint64_t SymValue = Resolver(Reloc, RelocSymValue, Addend);
|
uint64_t SymValue = Resolver(Reloc, RelocSymValue, Addend);
|
||||||
@ -4595,11 +4596,11 @@ void DumpStyle<ELFT>::printNonRelocatableStackSizes(
|
|||||||
// size. Check for an extra byte before we try to process the entry.
|
// size. Check for an extra byte before we try to process the entry.
|
||||||
if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1)) {
|
if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1)) {
|
||||||
reportError(
|
reportError(
|
||||||
FileStr,
|
|
||||||
createStringError(
|
createStringError(
|
||||||
object_error::parse_failed,
|
object_error::parse_failed,
|
||||||
"section %s ended while trying to extract a stack size entry",
|
"section %s ended while trying to extract a stack size entry",
|
||||||
SectionName.data()));
|
SectionName.data()),
|
||||||
|
FileStr);
|
||||||
}
|
}
|
||||||
uint64_t SymValue = Data.getAddress(&Offset);
|
uint64_t SymValue = Data.getAddress(&Offset);
|
||||||
printFunctionStackSize(Obj, SymValue,
|
printFunctionStackSize(Obj, SymValue,
|
||||||
@ -4689,10 +4690,10 @@ void DumpStyle<ELFT>::printRelocatableStackSizes(
|
|||||||
RelocSec.getName(RelocSectionName);
|
RelocSec.getName(RelocSectionName);
|
||||||
StringRef RelocName = EF->getRelocationTypeName(Reloc.getType());
|
StringRef RelocName = EF->getRelocationTypeName(Reloc.getType());
|
||||||
reportError(
|
reportError(
|
||||||
FileStr,
|
|
||||||
createStringError(object_error::parse_failed,
|
createStringError(object_error::parse_failed,
|
||||||
"unsupported relocation type in section %s: %s",
|
"unsupported relocation type in section %s: %s",
|
||||||
RelocSectionName.data(), RelocName.data()));
|
RelocSectionName.data(), RelocName.data()),
|
||||||
|
FileStr);
|
||||||
}
|
}
|
||||||
this->printStackSize(Obj, Reloc, FunctionSec, StackSizeSectionName,
|
this->printStackSize(Obj, Reloc, FunctionSec, StackSizeSectionName,
|
||||||
Resolver, Data);
|
Resolver, Data);
|
||||||
@ -5568,7 +5569,7 @@ void LLVMStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
|
|||||||
for (const auto &Note : Obj->notes(P, Err))
|
for (const auto &Note : Obj->notes(P, Err))
|
||||||
ProcessNote(Note);
|
ProcessNote(Note);
|
||||||
if (Err)
|
if (Err)
|
||||||
error(std::move(Err));
|
reportError(std::move(Err), this->FileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const auto &S : unwrapOrError(this->FileName, Obj->sections())) {
|
for (const auto &S : unwrapOrError(this->FileName, Obj->sections())) {
|
||||||
@ -5580,7 +5581,7 @@ void LLVMStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
|
|||||||
for (const auto &Note : Obj->notes(S, Err))
|
for (const auto &Note : Obj->notes(S, Err))
|
||||||
ProcessNote(Note);
|
ProcessNote(Note);
|
||||||
if (Err)
|
if (Err)
|
||||||
error(std::move(Err));
|
reportError(std::move(Err), this->FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,9 @@ void Dumper::printRuntimeFunction(const Context &Ctx,
|
|||||||
resolveRelocation(Ctx, Section, SectionOffset + 8, XData, Offset);
|
resolveRelocation(Ctx, Section, SectionOffset + 8, XData, Offset);
|
||||||
|
|
||||||
ArrayRef<uint8_t> Contents;
|
ArrayRef<uint8_t> Contents;
|
||||||
error(Ctx.COFF.getSectionContents(XData, Contents));
|
if (Error E = Ctx.COFF.getSectionContents(XData, Contents))
|
||||||
|
reportError(std::move(E), Ctx.COFF.getFileName());
|
||||||
|
|
||||||
if (Contents.empty())
|
if (Contents.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -311,7 +313,9 @@ void Dumper::printData(const Context &Ctx) {
|
|||||||
|
|
||||||
const coff_section *PData = Ctx.COFF.getCOFFSection(Section);
|
const coff_section *PData = Ctx.COFF.getCOFFSection(Section);
|
||||||
ArrayRef<uint8_t> Contents;
|
ArrayRef<uint8_t> Contents;
|
||||||
error(Ctx.COFF.getSectionContents(PData, Contents));
|
|
||||||
|
if (Error E = Ctx.COFF.getSectionContents(PData, Contents))
|
||||||
|
reportError(std::move(E), Ctx.COFF.getFileName());
|
||||||
if (Contents.empty())
|
if (Contents.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -382,10 +382,12 @@ LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reportError(StringRef Input, Error Err) {
|
void reportError(Error Err, StringRef Input) {
|
||||||
|
assert(Err);
|
||||||
if (Input == "-")
|
if (Input == "-")
|
||||||
Input = "<stdin>";
|
Input = "<stdin>";
|
||||||
error(createFileError(Input, std::move(Err)));
|
handleAllErrors(createFileError(Input, std::move(Err)),
|
||||||
|
[&](const ErrorInfoBase &EI) { reportError(EI.message()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void reportWarning(Twine Msg) {
|
void reportWarning(Twine Msg) {
|
||||||
@ -406,13 +408,6 @@ void warn(Error Err) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(Error EC) {
|
|
||||||
if (!EC)
|
|
||||||
return;
|
|
||||||
handleAllErrors(std::move(EC),
|
|
||||||
[&](const ErrorInfoBase &EI) { reportError(EI.message()); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void error(std::error_code EC) {
|
void error(std::error_code EC) {
|
||||||
if (!EC)
|
if (!EC)
|
||||||
return;
|
return;
|
||||||
@ -421,8 +416,9 @@ void error(std::error_code EC) {
|
|||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
static void reportError(StringRef Input, std::error_code EC) {
|
static void reportError(std::error_code EC, StringRef Input) {
|
||||||
reportError(Input, errorCodeToError(EC));
|
assert(EC != readobj_error::success);
|
||||||
|
reportError(errorCodeToError(EC), Input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isMipsArch(unsigned Arch) {
|
static bool isMipsArch(unsigned Arch) {
|
||||||
@ -482,7 +478,7 @@ static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer,
|
|||||||
|
|
||||||
std::unique_ptr<ObjDumper> Dumper;
|
std::unique_ptr<ObjDumper> Dumper;
|
||||||
if (std::error_code EC = createDumper(Obj, Writer, Dumper))
|
if (std::error_code EC = createDumper(Obj, Writer, Dumper))
|
||||||
reportError(FileStr, EC);
|
reportError(EC, FileStr);
|
||||||
|
|
||||||
if (opts::Output == opts::LLVM || opts::InputFilenames.size() > 1 || A) {
|
if (opts::Output == opts::LLVM || opts::InputFilenames.size() > 1 || A) {
|
||||||
Writer.startLine() << "\n";
|
Writer.startLine() << "\n";
|
||||||
@ -604,9 +600,8 @@ static void dumpArchive(const Archive *Arc, ScopedPrinter &Writer) {
|
|||||||
for (auto &Child : Arc->children(Err)) {
|
for (auto &Child : Arc->children(Err)) {
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
reportError(Arc->getFileName(), std::move(E));
|
reportError(std::move(E), Arc->getFileName());
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ObjectFile *Obj = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
|
if (ObjectFile *Obj = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
|
||||||
@ -614,10 +609,10 @@ static void dumpArchive(const Archive *Arc, ScopedPrinter &Writer) {
|
|||||||
else if (COFFImportFile *Imp = dyn_cast<COFFImportFile>(&*ChildOrErr.get()))
|
else if (COFFImportFile *Imp = dyn_cast<COFFImportFile>(&*ChildOrErr.get()))
|
||||||
dumpCOFFImportFile(Imp, Writer);
|
dumpCOFFImportFile(Imp, Writer);
|
||||||
else
|
else
|
||||||
reportError(Arc->getFileName(), readobj_error::unrecognized_file_format);
|
reportError(readobj_error::unrecognized_file_format, Arc->getFileName());
|
||||||
}
|
}
|
||||||
if (Err)
|
if (Err)
|
||||||
reportError(Arc->getFileName(), std::move(Err));
|
reportError(std::move(Err), Arc->getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dumps each object file in \a MachO Universal Binary;
|
/// Dumps each object file in \a MachO Universal Binary;
|
||||||
@ -627,9 +622,8 @@ static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary,
|
|||||||
Expected<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile();
|
Expected<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile();
|
||||||
if (ObjOrErr)
|
if (ObjOrErr)
|
||||||
dumpObject(&*ObjOrErr.get(), Writer);
|
dumpObject(&*ObjOrErr.get(), Writer);
|
||||||
else if (auto E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError())) {
|
else if (auto E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError()))
|
||||||
reportError(UBinary->getFileName(), ObjOrErr.takeError());
|
reportError(ObjOrErr.takeError(), UBinary->getFileName());
|
||||||
}
|
|
||||||
else if (Expected<std::unique_ptr<Archive>> AOrErr = Obj.getAsArchive())
|
else if (Expected<std::unique_ptr<Archive>> AOrErr = Obj.getAsArchive())
|
||||||
dumpArchive(&*AOrErr.get(), Writer);
|
dumpArchive(&*AOrErr.get(), Writer);
|
||||||
}
|
}
|
||||||
@ -640,7 +634,7 @@ static void dumpWindowsResourceFile(WindowsResource *WinRes,
|
|||||||
ScopedPrinter &Printer) {
|
ScopedPrinter &Printer) {
|
||||||
WindowsRes::Dumper Dumper(WinRes, Printer);
|
WindowsRes::Dumper Dumper(WinRes, Printer);
|
||||||
if (auto Err = Dumper.printData())
|
if (auto Err = Dumper.printData())
|
||||||
reportError(WinRes->getFileName(), std::move(Err));
|
reportError(std::move(Err), WinRes->getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -649,7 +643,7 @@ static void dumpInput(StringRef File, ScopedPrinter &Writer) {
|
|||||||
// Attempt to open the binary.
|
// Attempt to open the binary.
|
||||||
Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(File);
|
Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(File);
|
||||||
if (!BinaryOrErr)
|
if (!BinaryOrErr)
|
||||||
reportError(File, BinaryOrErr.takeError());
|
reportError(BinaryOrErr.takeError(), File);
|
||||||
Binary &Binary = *BinaryOrErr.get().getBinary();
|
Binary &Binary = *BinaryOrErr.get().getBinary();
|
||||||
|
|
||||||
if (Archive *Arc = dyn_cast<Archive>(&Binary))
|
if (Archive *Arc = dyn_cast<Archive>(&Binary))
|
||||||
@ -664,7 +658,7 @@ static void dumpInput(StringRef File, ScopedPrinter &Writer) {
|
|||||||
else if (WindowsResource *WinRes = dyn_cast<WindowsResource>(&Binary))
|
else if (WindowsResource *WinRes = dyn_cast<WindowsResource>(&Binary))
|
||||||
dumpWindowsResourceFile(WinRes, Writer);
|
dumpWindowsResourceFile(WinRes, Writer);
|
||||||
else
|
else
|
||||||
reportError(File, readobj_error::unrecognized_file_format);
|
reportError(readobj_error::unrecognized_file_format, File);
|
||||||
|
|
||||||
CVTypes.Binaries.push_back(std::move(*BinaryOrErr));
|
CVTypes.Binaries.push_back(std::move(*BinaryOrErr));
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,16 @@ namespace llvm {
|
|||||||
|
|
||||||
// Various helper functions.
|
// Various helper functions.
|
||||||
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
|
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
|
||||||
void reportError(StringRef Input, Error Err);
|
void reportError(Error Err, StringRef Input);
|
||||||
void reportWarning(Twine Msg);
|
void reportWarning(Twine Msg);
|
||||||
void reportWarning(StringRef Input, Error Err);
|
void reportWarning(StringRef Input, Error Err);
|
||||||
void warn(llvm::Error Err);
|
void warn(llvm::Error Err);
|
||||||
void error(std::error_code EC);
|
void error(std::error_code EC);
|
||||||
void error(llvm::Error EC);
|
|
||||||
|
|
||||||
template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) {
|
template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) {
|
||||||
if (EO)
|
if (EO)
|
||||||
return *EO;
|
return *EO;
|
||||||
reportError(Input, EO.takeError());
|
reportError(EO.takeError(), Input);
|
||||||
llvm_unreachable("reportError shouldn't return in this case");
|
llvm_unreachable("reportError shouldn't return in this case");
|
||||||
}
|
}
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user