Index: llvm/test/tools/llvm-readobj/gnu-notes.test =================================================================== --- llvm/test/tools/llvm-readobj/gnu-notes.test +++ llvm/test/tools/llvm-readobj/gnu-notes.test @@ -3,6 +3,8 @@ # RUN: yaml2obj --docnum=1 %s > %t1.so # RUN: llvm-readelf --notes %t1.so | FileCheck %s --check-prefix=GNU --strict-whitespace --match-full-lines # RUN: llvm-readobj --notes %t1.so | FileCheck %s --check-prefix=LLVM +# RUN: llvm-objcopy --strip-all %t1.so +# RUN: llvm-readobj --notes %t1.so | FileCheck %s --check-prefix=LLVM-STRIPPED # GNU:Displaying notes found at file offset 0x00000200 with length 0x00000020: # GNU-NEXT: Owner Data size Description @@ -53,6 +55,19 @@ # LLVM-NEXT: } # LLVM-NEXT: ] +# LLVM-STRIPPED: Notes [ +# LLVM-STRIPPED-NEXT: NoteSection { +# LLVM-STRIPPED-NEXT: Offset: 0x40 +# LLVM-STRIPPED-NEXT: Size: 0x20 +# LLVM-STRIPPED-NEXT: Note { +# LLVM-STRIPPED-NEXT: Owner: GNU +# LLVM-STRIPPED-NEXT: Data size: 0x10 +# LLVM-STRIPPED-NEXT: Type: NT_GNU_BUILD_ID (unique build ID bitstring) +# LLVM-STRIPPED-NEXT: Build ID: 4fcb712aa6387724a9f465a32cd8c14b +# LLVM-STRIPPED-NEXT: } +# LLVM-STRIPPED-NEXT: } +# LLVM-STRIPPED-NEXT: ] + --- !ELF FileHeader: Class: ELFCLASS64 Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -4502,7 +4502,7 @@ } }; - if (Obj->getHeader()->e_type == ELF::ET_CORE) { + if (Obj->getHeader()->e_type == ELF::ET_CORE || Obj->sections()->empty()) { for (const auto &P : unwrapOrError(this->FileName, Obj->program_headers())) { if (P.p_type != PT_NOTE)