mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-04 02:47:25 +00:00
Replace a report_fatal_error with an ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
074ecc25c3
commit
7446318ad9
@ -132,9 +132,9 @@ public:
|
||||
}
|
||||
|
||||
/// \brief Iterate over program header table.
|
||||
const Elf_Phdr_Range program_headers() const {
|
||||
ErrorOr<Elf_Phdr_Range> program_headers() const {
|
||||
if (Header->e_phnum && Header->e_phentsize != sizeof(Elf_Phdr))
|
||||
report_fatal_error("Invalid program header size");
|
||||
return object_error::parse_failed;
|
||||
auto *Begin = reinterpret_cast<const Elf_Phdr *>(base() + Header->e_phoff);
|
||||
return makeArrayRef(Begin, Begin+Header->e_phnum);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ RUN: not llvm-readobj -program-headers \
|
||||
RUN: %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=PHENTSIZE %s
|
||||
|
||||
PHENTSIZE: Invalid program header size
|
||||
PHENTSIZE: Invalid data was encountered while parsing the file.
|
||||
|
||||
RUN: not llvm-readobj -dynamic-table \
|
||||
RUN: %p/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 2>&1 | \
|
||||
|
@ -24,7 +24,10 @@ using namespace llvm::object;
|
||||
template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) {
|
||||
typedef ELFFile<ELFT> ELFO;
|
||||
outs() << "Program Header:\n";
|
||||
for (const typename ELFO::Elf_Phdr &Phdr : o->program_headers()) {
|
||||
auto ProgramHeaderOrError = o->program_headers();
|
||||
if (std::error_code EC = ProgramHeaderOrError.getError())
|
||||
report_fatal_error(EC.message());
|
||||
for (const typename ELFO::Elf_Phdr &Phdr : *ProgramHeaderOrError) {
|
||||
switch (Phdr.p_type) {
|
||||
case ELF::PT_LOAD:
|
||||
outs() << " LOAD ";
|
||||
|
@ -1305,7 +1305,7 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile<ELFT> *Obj, ScopedPrinter &Writer)
|
||||
: ObjDumper(Writer), Obj(Obj) {
|
||||
|
||||
SmallVector<const Elf_Phdr *, 4> LoadSegments;
|
||||
for (const Elf_Phdr &Phdr : Obj->program_headers()) {
|
||||
for (const Elf_Phdr &Phdr : unwrapOrError(Obj->program_headers())) {
|
||||
if (Phdr.p_type == ELF::PT_DYNAMIC) {
|
||||
DynamicTable = createDRIFrom(&Phdr, sizeof(Elf_Dyn));
|
||||
continue;
|
||||
@ -2910,7 +2910,7 @@ void GNUStyle<ELFT>::printProgramHeaders(const ELFO *Obj) {
|
||||
else
|
||||
OS << " Type Offset VirtAddr PhysAddr FileSiz "
|
||||
<< "MemSiz Flg Align\n";
|
||||
for (const auto &Phdr : Obj->program_headers()) {
|
||||
for (const auto &Phdr : unwrapOrError(Obj->program_headers())) {
|
||||
Type = getElfPtType(Header->e_machine, Phdr.p_type);
|
||||
Offset = to_string(format_hex(Phdr.p_offset, 8));
|
||||
VMA = to_string(format_hex(Phdr.p_vaddr, Width));
|
||||
@ -2937,7 +2937,7 @@ void GNUStyle<ELFT>::printProgramHeaders(const ELFO *Obj) {
|
||||
}
|
||||
OS << "\n Section to Segment mapping:\n Segment Sections...\n";
|
||||
int Phnum = 0;
|
||||
for (const Elf_Phdr &Phdr : Obj->program_headers()) {
|
||||
for (const Elf_Phdr &Phdr : unwrapOrError(Obj->program_headers())) {
|
||||
std::string Sections;
|
||||
OS << format(" %2.2d ", Phnum++);
|
||||
for (const Elf_Shdr &Sec : unwrapOrError(Obj->sections())) {
|
||||
@ -3268,7 +3268,7 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
|
||||
};
|
||||
|
||||
if (IsCore) {
|
||||
for (const auto &P : Obj->program_headers())
|
||||
for (const auto &P : unwrapOrError(Obj->program_headers()))
|
||||
if (P.p_type == PT_NOTE)
|
||||
process(P.p_offset, P.p_filesz);
|
||||
} else {
|
||||
@ -3630,7 +3630,7 @@ template <class ELFT>
|
||||
void LLVMStyle<ELFT>::printProgramHeaders(const ELFO *Obj) {
|
||||
ListScope L(W, "ProgramHeaders");
|
||||
|
||||
for (const Elf_Phdr &Phdr : Obj->program_headers()) {
|
||||
for (const Elf_Phdr &Phdr : unwrapOrError(Obj->program_headers())) {
|
||||
DictScope P(W, "ProgramHeader");
|
||||
W.printHex("Type",
|
||||
getElfSegmentType(Obj->getHeader()->e_machine, Phdr.p_type),
|
||||
|
Loading…
x
Reference in New Issue
Block a user