diff options
author | Tim Northover <tnorthover@apple.com> | 2016-11-15 20:26:01 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2016-11-15 20:26:01 +0000 |
commit | bf55f7ea59c110df5d62d1c9b3866d374f5a86d0 (patch) | |
tree | d4a65b1bacdfb447194f6f42d2a0ac18af6a7b56 /llvm/tools/llvm-objdump | |
parent | d4bb5e483118cfa2634a21689afa217134d98eab (diff) | |
download | bcm5719-llvm-bf55f7ea59c110df5d62d1c9b3866d374f5a86d0.tar.gz bcm5719-llvm-bf55f7ea59c110df5d62d1c9b3866d374f5a86d0.zip |
llvm-objdump: deal with unexpected object files more gracefully.
Specifically, we don't want to segfault on release builds, so print the problem
instead.
llvm-svn: 287022
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 249ab7e90a3..7e61485f2ac 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -7072,8 +7072,10 @@ printMachOCompactUnwindSection(const MachOObjectFile *Obj, std::map<uint64_t, SymbolRef> &Symbols, const SectionRef &CompactUnwind) { - assert(Obj->isLittleEndian() && - "There should not be a big-endian .o with __compact_unwind"); + if (!Obj->isLittleEndian()) { + outs() << "Skipping big-endian __compact_unwind section\n"; + return; + } bool Is64 = Obj->is64Bit(); uint32_t PointerSize = Is64 ? sizeof(uint64_t) : sizeof(uint32_t); @@ -7105,8 +7107,10 @@ printMachOCompactUnwindSection(const MachOObjectFile *Obj, Entry.PersonalityReloc = Reloc; else if (OffsetInEntry == 2 * PointerSize + 2 * sizeof(uint32_t)) Entry.LSDAReloc = Reloc; - else - llvm_unreachable("Unexpected relocation in __compact_unwind section"); + else { + outs() << "Invalid relocation in __compact_unwind section\n"; + return; + } } // Finally, we're ready to print the data we've gathered. @@ -7212,8 +7216,10 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj, std::map<uint64_t, SymbolRef> &Symbols, const SectionRef &UnwindInfo) { - assert(Obj->isLittleEndian() && - "There should not be a big-endian .o with __unwind_info"); + if (!Obj->isLittleEndian()) { + outs() << "Skipping big-endian __unwind_info section\n"; + return; + } outs() << "Contents of __unwind_info section:\n"; @@ -7228,7 +7234,10 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj, uint32_t Version = readNext<uint32_t>(Pos); outs() << " Version: " << format("0x%" PRIx32, Version) << '\n'; - assert(Version == 1 && "only understand version 1"); + if (Version != 1) { + outs() << " Skipping section with unknown version\n"; + return; + } uint32_t CommonEncodingsStart = readNext<uint32_t>(Pos); outs() << " Common encodings array section offset: " @@ -7368,7 +7377,8 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj, printCompressedSecondLevelUnwindPage(Pos, IndexEntries[i].FunctionOffset, CommonEncodings); else - llvm_unreachable("Do not know how to print this kind of 2nd level page"); + outs() << " Skipping 2nd level page with unknown kind " << Kind + << '\n'; } } |