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,28 @@ +# RUN: yaml2obj %s > %t +# RUN: llvm-objdump --archive-headers %t > %t.out1 +# RUN: llvm-objdump -a %t > %t.out2 +# RUN: cmp %t.out1 %t.out2 +# RUN: FileCheck %s --input-file=%t.out1 + +# If this test 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 + 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); }