diff --git a/lld/test/ELF/partition-notes.s b/lld/test/ELF/partition-notes.s --- a/lld/test/ELF/partition-notes.s +++ b/lld/test/ELF/partition-notes.s @@ -9,20 +9,38 @@ // RUN: llvm-objcopy --extract-main-partition %t %t0 // RUN: llvm-objcopy --extract-partition=part1 %t %t1 -// RUN: llvm-readelf --all %t0 | FileCheck --check-prefixes=CHECK,PART0 %s -// RUN: llvm-readelf --all %t1 | FileCheck --check-prefixes=CHECK,PART1 %s - -// CHECK: Program Headers: -// CHECK: NOTE 0x{{0*}}[[NOTE_OFFSET:[^ ]*]] - -// CHECK: Displaying notes found at file offset 0x{{0*}}[[NOTE_OFFSET]] -// CHECK-NEXT: Owner -// CHECK-NEXT: foo 0x00000004 NT_VERSION (version) -// CHECK-NEXT: description data: 62 61 72 00 -// CHECK-NEXT: Displaying notes -// CHECK-NEXT: Owner -// CHECK-NEXT: GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring) -// CHECK-NEXT: Build ID: 08b93eab87177a2356d1b0d1148339463f98dac2 +// RUN: llvm-readobj --all %t0 | FileCheck --check-prefixes=CHECK,PART0 %s +// RUN: llvm-readobj --all %t1 | FileCheck --check-prefixes=CHECK,PART1 %s + +// CHECK: Type: PT_NOTE +// CHECK-NEXT: Offset: 0x{{0*}}[[NOTE_OFFSET:[^ ]*]] + +// CHECK: Notes [ +// CHECK-NEXT: NoteSection { +// CHECK-NEXT: Name: .note.obj +// CHECK-NEXT: Offset: 0x{{0*}}[[NOTE_OFFSET]] +// CHECK-NEXT: Size: +// CHECK-NEXT: Note { +// CHECK-NEXT: Owner: foo +// CHECK-NEXT: Data size: 0x4 +// CHECK-NEXT: Type: NT_VERSION (version) +// CHECK-NEXT: Description data ( +// CHECK-NEXT: 0000: 62617200 |bar.| +// CHECK-NEXT: ) +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: NoteSection { +// CHECK-NEXT: Name: .note.gnu.build-id +// CHECK-NEXT: Offset: +// CHECK-NEXT: Size: +// CHECK-NEXT: Note { +// CHECK-NEXT: Owner: GNU +// CHECK-NEXT: Data size: +// CHECK-NEXT: Type: NT_GNU_BUILD_ID (unique build ID bitstring) +// CHECK-NEXT: Build ID: 08b93eab87177a2356d1b0d1148339463f98dac2 +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] .section .llvm_sympart,"",@llvm_sympart .asciz "part1" diff --git a/llvm/test/CodeGen/AMDGPU/code-object-v3.ll b/llvm/test/CodeGen/AMDGPU/code-object-v3.ll --- a/llvm/test/CodeGen/AMDGPU/code-object-v3.ll +++ b/llvm/test/CodeGen/AMDGPU/code-object-v3.ll @@ -59,7 +59,7 @@ ; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000100 {{[0-9]+}} FUNC GLOBAL PROTECTED {{[0-9]+}} fsub ; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000040 64 OBJECT GLOBAL DEFAULT {{[0-9]+}} fsub.kd -; OSABI-AMDHSA-ELF: Displaying notes found at file offset +; OSABI-AMDHSA-ELF: Displaying notes found in: .note ; OSABI-AMDHSA-ELF: AMDGPU 0x{{[0-9a-f]+}} NT_AMDGPU_METADATA (AMDGPU Metadata) define amdgpu_kernel void @fadd( diff --git a/llvm/test/tools/llvm-objcopy/ELF/add-note.test b/llvm/test/tools/llvm-objcopy/ELF/add-note.test --- a/llvm/test/tools/llvm-objcopy/ELF/add-note.test +++ b/llvm/test/tools/llvm-objcopy/ELF/add-note.test @@ -24,6 +24,7 @@ # CHECK: Notes [ # CHECK-NEXT: NoteSection { +# CHECK-NEXT: Name: .note.gnu.build-id # CHECK-NEXT: Offset: # CHECK-NEXT: Size: # CHECK-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s b/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s --- a/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s +++ b/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s @@ -2,13 +2,14 @@ // RUN: llvm-readelf --notes %t | FileCheck %s --check-prefix=GNU // RUN: llvm-readobj --notes %t | FileCheck %s --check-prefix=LLVM -// GNU: Displaying notes found at file offset 0x00000040 with length 0x00000020: +// GNU: Displaying notes found in: .note.gnu.property // GNU-NEXT: Owner Data size Description // GNU-NEXT: GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 (property note) // GNU-NEXT: Properties: aarch64 feature: BTI, PAC // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.gnu.property // LLVM-NEXT: Offset: 0x40 // LLVM-NEXT: Size: 0x20 // LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/all.test b/llvm/test/tools/llvm-readobj/ELF/all.test --- a/llvm/test/tools/llvm-readobj/ELF/all.test +++ b/llvm/test/tools/llvm-readobj/ELF/all.test @@ -36,7 +36,7 @@ # GNU-ALL: Version needs section '.gnu.version_r' contains {{.*}} entries: # GNU-ALL: There are no section groups in this file. # GNU-ALL: Histogram for bucket list length (total of 1 buckets) -# GNU-ALL: Displaying notes found at file offset {{.*}} with length {{.*}}: +# GNU-ALL: Displaying notes found --- !ELF FileHeader: diff --git a/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test b/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test --- a/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test +++ b/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test @@ -2,12 +2,14 @@ # RUN: llvm-readelf --notes %t | FileCheck %s --check-prefix=GNU # RUN: llvm-readobj --elf-output-style LLVM --notes %t | FileCheck %s --check-prefix=LLVM -# GNU: Owner Data size Description +# GNU: Displaying notes found in: .note.ABI-tag +# GNU-NEXT: Owner Data size Description # GNU-NEXT: GNU 0x00000004 NT_GNU_ABI_TAG (ABI version tag) # GNU-NEXT: # LLVM: Notes [ # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: .note.ABI-tag # LLVM-NEXT: Offset: # LLVM-NEXT: Size: 0x14 # LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test --- a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test +++ b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test @@ -7,23 +7,24 @@ # RUN: llvm-readelf --notes %t1.stripped.so | FileCheck %s --check-prefix=GNU-STRIPPED --strict-whitespace --match-full-lines # RUN: llvm-readobj --notes %t1.stripped.so | FileCheck %s --check-prefix=LLVM-STRIPPED -# GNU:Displaying notes found at file offset 0x00000078 with length 0x00000020: +# GNU:Displaying notes found in: .note.ABI-tag # GNU-NEXT: Owner Data size Description # GNU-NEXT: GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag) # GNU-NEXT: OS: Linux, ABI: 2.6.32 -# GNU:Displaying notes found at file offset 0x00000098 with length 0x00000020: +# GNU:Displaying notes found in: .note.gnu.build-id # GNU-NEXT: Owner Data size Description # GNU-NEXT: GNU 0x00000010 NT_GNU_BUILD_ID (unique build ID bitstring) # GNU-NEXT: Build ID: 4fcb712aa6387724a9f465a32cd8c14b -# GNU:Displaying notes found at file offset 0x000000b8 with length 0x0000001c: +# GNU:Displaying notes found in: .note.gnu.gold-version # GNU-NEXT: Owner Data size Description # GNU-NEXT: GNU 0x00000009 NT_GNU_GOLD_VERSION (gold version) # GNU-NEXT: Version: gold 1.11 # LLVM: Notes [ # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: .note.ABI-tag # LLVM-NEXT: Offset: 0x78 # LLVM-NEXT: Size: 0x20 # LLVM-NEXT: Note { @@ -35,6 +36,7 @@ # LLVM-NEXT: } # LLVM-NEXT: } # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: .note.gnu.build-id # LLVM-NEXT: Offset: 0x98 # LLVM-NEXT: Size: 0x20 # LLVM-NEXT: Note { @@ -45,6 +47,7 @@ # LLVM-NEXT: } # LLVM-NEXT: } # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: .note.gnu.gold-version # LLVM-NEXT: Offset: 0xB8 # LLVM-NEXT: Size: 0x1C # LLVM-NEXT: Note { @@ -56,8 +59,10 @@ # LLVM-NEXT: } # LLVM-NEXT: ] +## Note: the section name is here because the section header table is not present. # LLVM-STRIPPED: Notes [ # LLVM-STRIPPED-NEXT: NoteSection { +# LLVM-STRIPPED-NEXT: Name: # LLVM-STRIPPED-NEXT: Offset: 0x78 # LLVM-STRIPPED-NEXT: Size: 0x20 # LLVM-STRIPPED-NEXT: Note { @@ -69,6 +74,8 @@ # LLVM-STRIPPED-NEXT: } # LLVM-STRIPPED-NEXT: ] +## Note: offset and length printed instead of "found in: .note.gnu.build-id" +## because the section header table is not present. # GNU-STRIPPED:Displaying notes found at file offset 0x00000078 with length 0x00000020: # GNU-STRIPPED-NEXT: Owner Data size Description # GNU-STRIPPED-NEXT: GNU 0x00000010 NT_GNU_BUILD_ID (unique build ID bitstring) diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amd.s b/llvm/test/tools/llvm-readobj/ELF/note-amd.s --- a/llvm/test/tools/llvm-readobj/ELF/note-amd.s +++ b/llvm/test/tools/llvm-readobj/ELF/note-amd.s @@ -4,7 +4,7 @@ // RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM // RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU -// GNU: Displaying notes found +// GNU: Displaying notes found in: .note.no.desc // GNU-NEXT: Owner Data size Description // GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata) // GNU-NEXT: HSA Metadata: @@ -12,7 +12,7 @@ // GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_ISA (ISA Version) // GNU-NEXT: ISA Version: // GNU-NEXT: {{^ +$}} -// GNU-NEXT: Displaying notes found +// GNU-NEXT: Displaying notes found in: .note.desc // GNU-NEXT: Owner Data size Description // GNU-NEXT: AMD 0x0000000a NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata) // GNU-NEXT: HSA Metadata: @@ -20,12 +20,13 @@ // GNU-NEXT: AMD 0x00000009 NT_AMD_AMDGPU_ISA (ISA Version) // GNU-NEXT: ISA Version: // GNU-NEXT: isa_blah -// GNU-NEXT: Displaying notes found +// GNU-NEXT: Displaying notes found in: .note.other // GNU-NEXT: Owner Data size Description // GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_PAL_METADATA (PAL Metadata) // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.no.desc // LLVM-NEXT: Offset: // LLVM-NEXT: Size: // LLVM-NEXT: Note { @@ -42,6 +43,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.desc // LLVM-NEXT: Offset: // LLVM-NEXT: Size: // LLVM-NEXT: Note { @@ -58,6 +60,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.other // LLVM-NEXT: Offset: // LLVM-NEXT: Size: // LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test b/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test --- a/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test +++ b/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test @@ -2,7 +2,7 @@ # RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM # RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU -# GNU: Displaying notes found +# GNU: Displaying notes found in: .note.foo # GNU-NEXT: Owner Data size Description # GNU-NEXT: AMDGPU 0x000000e6 NT_AMDGPU_METADATA (AMDGPU Metadata) # GNU-NEXT: AMDGPU Metadata: @@ -25,6 +25,7 @@ # LLVM: Notes [ # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: .note.foo # LLVM-NEXT: Offset: # LLVM-NEXT: Size: # LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test b/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test --- a/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test +++ b/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test @@ -65,6 +65,7 @@ # LLVM: Notes [ # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: # LLVM-NEXT: Offset: # LLVM-NEXT: Size: # LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-core.test b/llvm/test/tools/llvm-readobj/ELF/note-core.test --- a/llvm/test/tools/llvm-readobj/ELF/note-core.test +++ b/llvm/test/tools/llvm-readobj/ELF/note-core.test @@ -30,6 +30,7 @@ # LLVM: Notes [ # LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: # LLVM-NEXT: Offset: # LLVM-NEXT: Size: # LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-freebsd.s b/llvm/test/tools/llvm-readobj/ELF/note-freebsd.s --- a/llvm/test/tools/llvm-readobj/ELF/note-freebsd.s +++ b/llvm/test/tools/llvm-readobj/ELF/note-freebsd.s @@ -4,20 +4,21 @@ // RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM // RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU -// GNU: Displaying notes found +// GNU: Displaying notes found in: .note.foo // GNU-NEXT: Owner Data size Description // GNU-NEXT: FreeBSD 0x00000000 NT_THRMISC (thrmisc structure) // GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_PROC (proc data) -// GNU-NEXT: Displaying notes found +// GNU-NEXT: Displaying notes found in: .note.bar // GNU-NEXT: Owner Data size Description // GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_FILES (files data) -// GNU-NEXT: Displaying notes found +// GNU-NEXT: Displaying notes found in: .note.baz // GNU-NEXT: Owner Data size Description // GNU-NEXT: FreeBSD 0x0000001c Unknown note type (0x00000003) // GNU-NEXT: description data: 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 00 00 // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.foo // LLVM-NEXT: Offset: // LLVM-NEXT: Size: // LLVM-NEXT: Note { @@ -32,6 +33,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.bar // LLVM-NEXT: Offset: 0x68 // LLVM-NEXT: Size: 0x14 // LLVM-NEXT: Note { @@ -41,6 +43,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.baz // LLVM-NEXT: Offset: 0x7C // LLVM-NEXT: Size: 0x30 // LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-generic.s b/llvm/test/tools/llvm-readobj/ELF/note-generic.s --- a/llvm/test/tools/llvm-readobj/ELF/note-generic.s +++ b/llvm/test/tools/llvm-readobj/ELF/note-generic.s @@ -4,24 +4,25 @@ // RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM // RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU -// GNU: Displaying notes found at file offset 0x00000040 with length 0x00000010: +// GNU: Displaying notes found in: .note.version // GNU-NEXT: Owner Data size Description // GNU-NEXT: XYZ 0x00000000 NT_VERSION (version) -// GNU: Displaying notes found at file offset 0x00000050 with length 0x00000010: +// GNU: Displaying notes found in: .note.arch // GNU-NEXT: Owner Data size Description // GNU-NEXT: XYZ 0x00000000 NT_ARCH (architecture) -// GNU: Displaying notes found at file offset 0x00000060 with length 0x00000010: +// GNU: Displaying notes found in: .note.open // GNU-NEXT: Owner Data size Description // GNU-NEXT: XYZ 0x00000000 OPEN -// GNU: Displaying notes found at file offset 0x00000070 with length 0x00000010: +// GNU: Displaying notes found in: .note.func // GNU-NEXT: Owner Data size Description // GNU-NEXT: XYZ 0x00000000 func // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.version // LLVM-NEXT: Offset: 0x40 // LLVM-NEXT: Size: 0x10 // LLVM-NEXT: Note { @@ -31,6 +32,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.arch // LLVM-NEXT: Offset: 0x50 // LLVM-NEXT: Size: 0x10 // LLVM-NEXT: Note { @@ -40,6 +42,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.open // LLVM-NEXT: Offset: 0x60 // LLVM-NEXT: Size: 0x10 // LLVM-NEXT: Note { @@ -49,6 +52,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.func // LLVM-NEXT: Offset: 0x70 // LLVM-NEXT: Size: 0x10 // LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s --- a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s +++ b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s @@ -3,7 +3,7 @@ // RUN: llvm-readelf --notes %t | FileCheck %s --check-prefix=GNU // RUN: llvm-readobj --elf-output-style LLVM --notes %t | FileCheck %s --check-prefix=LLVM -// GNU: Displaying notes found at file offset 0x00000040 with length 0x000000f8: +// GNU: Displaying notes found in: .note.gnu.property // GNU-NEXT: Owner Data size Description // GNU-NEXT: GNU 0x000000e8 NT_GNU_PROPERTY_TYPE_0 (property note) // GNU-NEXT: Properties: stack size: 0x100 @@ -26,6 +26,7 @@ // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.gnu.property // LLVM-NEXT: Offset: 0x40 // LLVM-NEXT: Size: 0xF8 // LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s --- a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s +++ b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s @@ -3,13 +3,14 @@ // RUN: llvm-readelf --notes %t | FileCheck %s --check-prefix=GNU // RUN: llvm-readobj --elf-output-style LLVM --notes %t | FileCheck %s --check-prefix=LLVM -// GNU: Displaying notes found at file offset 0x00000040 with length 0x00000014: +// GNU: Displaying notes found in: .note.gnu.property // GNU-NEXT: Owner Data size Description // GNU-NEXT: GNU 0x00000004 NT_GNU_PROPERTY_TYPE_0 (property note) // GNU-NEXT: Properties: // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.gnu.property // LLVM-NEXT: Offset: 0x40 // LLVM-NEXT: Size: 0x14 // LLVM-NEXT: Note { diff --git a/llvm/test/tools/llvm-readobj/ELF/note-unknown.s b/llvm/test/tools/llvm-readobj/ELF/note-unknown.s --- a/llvm/test/tools/llvm-readobj/ELF/note-unknown.s +++ b/llvm/test/tools/llvm-readobj/ELF/note-unknown.s @@ -4,16 +4,17 @@ // RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM // RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU -// GNU: Displaying notes found at file offset 0x00000040 with length 0x00000010: +// GNU: Displaying notes found in: .note.foo // GNU-NEXT: Owner Data size Description // GNU-NEXT: XYZ 0x00000000 Unknown note type: (0x00000003) -// GNU-NEXT: Displaying notes found at file offset 0x00000050 with length 0x0000002c: +// GNU-NEXT: Displaying notes found in: .note.bar // GNU-NEXT: Owner Data size Description // GNU-NEXT: XYZ 0x0000001c Unknown note type: (0x00000003) // GNU-NEXT: description data: 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 00 00 // LLVM: Notes [ // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.foo // LLVM-NEXT: Offset: 0x40 // LLVM-NEXT: Size: 0x10 // LLVM-NEXT: Note { @@ -23,6 +24,7 @@ // LLVM-NEXT: } // LLVM-NEXT: } // LLVM-NEXT: NoteSection { +// LLVM-NEXT: Name: .note.bar // LLVM-NEXT: Offset: 0x50 // LLVM-NEXT: Size: 0x2C // LLVM-NEXT: Note { diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -5042,11 +5042,18 @@ template void GNUStyle::printNotes(const ELFFile *Obj) { - auto PrintHeader = [&](const typename ELFT::Off Offset, + auto PrintHeader = [&](Optional SecName, + const typename ELFT::Off Offset, const typename ELFT::Addr Size) { - OS << "Displaying notes found at file offset " << format_hex(Offset, 10) - << " with length " << format_hex(Size, 10) << ":\n" - << " Owner Data size \tDescription\n"; + OS << "Displaying notes found "; + + if (SecName) + OS << "in: " << *SecName << "\n"; + else + OS << "at file offset " << format_hex(Offset, 10) << " with length " + << format_hex(Size, 10) << ":\n"; + + OS << " Owner Data size \tDescription\n"; }; auto ProcessNote = [&](const Elf_Note &Note) { @@ -5111,7 +5118,8 @@ for (const auto &S : Sections) { if (S.sh_type != SHT_NOTE) continue; - PrintHeader(S.sh_offset, S.sh_size); + PrintHeader(expectedToOptional(Obj->getSectionName(&S)), S.sh_offset, + S.sh_size); Error Err = Error::success(); for (auto Note : Obj->notes(S, Err)) ProcessNote(Note); @@ -5123,7 +5131,7 @@ unwrapOrError(this->FileName, Obj->program_headers())) { if (P.p_type != PT_NOTE) continue; - PrintHeader(P.p_offset, P.p_filesz); + PrintHeader(/*SecName=*/None, P.p_offset, P.p_filesz); Error Err = Error::success(); for (auto Note : Obj->notes(P, Err)) ProcessNote(Note); @@ -6263,8 +6271,10 @@ void LLVMStyle::printNotes(const ELFFile *Obj) { ListScope L(W, "Notes"); - auto PrintHeader = [&](const typename ELFT::Off Offset, + auto PrintHeader = [&](Optional SecName, + const typename ELFT::Off Offset, const typename ELFT::Addr Size) { + W.printString("Name", SecName ? *SecName : ""); W.printHex("Offset", Offset); W.printHex("Size", Size); }; @@ -6331,7 +6341,8 @@ if (S.sh_type != SHT_NOTE) continue; DictScope D(W, "NoteSection"); - PrintHeader(S.sh_offset, S.sh_size); + PrintHeader(expectedToOptional(Obj->getSectionName(&S)), S.sh_offset, + S.sh_size); Error Err = Error::success(); for (auto Note : Obj->notes(S, Err)) ProcessNote(Note); @@ -6344,7 +6355,7 @@ if (P.p_type != PT_NOTE) continue; DictScope D(W, "NoteSection"); - PrintHeader(P.p_offset, P.p_filesz); + PrintHeader(/*SecName=*/None, P.p_offset, P.p_filesz); Error Err = Error::success(); for (auto Note : Obj->notes(P, Err)) ProcessNote(Note);