[llvm] r287022 - llvm-objdump: deal with unexpected object files more gracefully.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 15 12:26:02 PST 2016
Author: tnorthover
Date: Tue Nov 15 14:26:01 2016
New Revision: 287022
URL: http://llvm.org/viewvc/llvm-project?rev=287022&view=rev
Log:
llvm-objdump: deal with unexpected object files more gracefully.
Specifically, we don't want to segfault on release builds, so print the problem
instead.
Added:
llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-unwind.macho-x86_64 (with props)
llvm/trunk/test/tools/llvm-objdump/malformed-unwind-x86_64.test
Modified:
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Added: llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-unwind.macho-x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-unwind.macho-x86_64?rev=287022&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-unwind.macho-x86_64 (added) and llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-unwind.macho-x86_64 Tue Nov 15 14:26:01 2016 differ
Propchange: llvm/trunk/test/tools/llvm-objdump/Inputs/malformed-unwind.macho-x86_64
------------------------------------------------------------------------------
svn:executable = *
Added: llvm/trunk/test/tools/llvm-objdump/malformed-unwind-x86_64.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/malformed-unwind-x86_64.test?rev=287022&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/malformed-unwind-x86_64.test (added)
+++ llvm/trunk/test/tools/llvm-objdump/malformed-unwind-x86_64.test Tue Nov 15 14:26:01 2016
@@ -0,0 +1,5 @@
+# RUN: llvm-objdump -unwind-info %p/Inputs/malformed-unwind.macho-x86_64 | FileCheck %s
+
+# CHECK: Contents of __unwind_info section:
+# [...]
+# CHECK: Skipping 2nd level page with unknown kind 4
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=287022&r1=287021&r2=287022&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Tue Nov 15 14:26:01 2016
@@ -7072,8 +7072,10 @@ printMachOCompactUnwindSection(const Mac
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 Mac
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(
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(
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(
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';
}
}
More information about the llvm-commits
mailing list