[PATCH] D53690: [llvm-objdump] Don't Crash When Using `-a` on Non-Archives (PR39402)
Xing via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 29 04:54:22 PDT 2018
Higuoxing updated this revision to Diff 171484.
Higuoxing added a comment.
Fix typo. Thanks a lot for all of your help :)
https://reviews.llvm.org/D53690
Files:
test/tools/llvm-objdump/non-archive-object.test
tools/llvm-objdump/llvm-objdump.cpp
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -2305,8 +2305,8 @@
outs() << ":\tfile format " << o->getFileFormatName() << "\n\n";
}
- if (ArchiveHeaders && !MachOOpt)
- printArchiveChild(a->getFileName(), *c);
+ if (ArchiveHeaders && !MachOOpt && c)
+ printArchiveChild(ArchiveName, *c);
if (Disassemble)
DisassembleObject(o, Relocations);
if (Relocations && !Disassemble)
@@ -2359,8 +2359,8 @@
<< ":\tfile format COFF-import-file"
<< "\n\n";
- if (ArchiveHeaders && !MachOOpt)
- printArchiveChild(A->getFileName(), *C);
+ if (ArchiveHeaders && !MachOOpt && C)
+ printArchiveChild(ArchiveName, *C);
if (SymbolTable)
printCOFFSymbolTable(I);
}
Index: test/tools/llvm-objdump/non-archive-object.test
===================================================================
--- test/tools/llvm-objdump/non-archive-object.test
+++ test/tools/llvm-objdump/non-archive-object.test
@@ -0,0 +1,25 @@
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objdump -a %t | FileCheck %s
+
+# If this test has not crashed, then this test passed.
+# CHECK: file format ELF64-x86-64
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x0000000000000010
+ Size: 64
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000010
+ Content: "01234567"
+ Size: 4
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53690.171484.patch
Type: text/x-patch
Size: 1796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181029/42fd2f4a/attachment.bin>
More information about the llvm-commits
mailing list