This matches GNU binutils.
Reviewed By: rupprecht, jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D96010
// GNU-NEXT: Owner Data size Description
// GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
// GNU-NEXT: HSA Metadata:
-// GNU-NEXT: {{^ +$}}
+// GNU-NEXT: {{^ $}}
// GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_ISA (ISA Version)
// GNU-NEXT: ISA Version:
-// GNU-NEXT: {{^ +$}}
+// GNU-NEXT: {{^ $}}
+// GNU-EMPTY:
// 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: AMD 0x00000009 NT_AMD_AMDGPU_ISA (ISA Version)
// GNU-NEXT: ISA Version:
// GNU-NEXT: isa_blah
+// GNU-EMPTY:
// 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)
+// GNU-EMPTY:
// LLVM: Notes [
// LLVM-NEXT: NoteSection {
# GNU-NEXT: .vgpr_count: 7
# GNU-NEXT: .wavefront_size: 5
# GNU-NEXT: ...
+# GNU-EMPTY:
# LLVM: Notes [
# LLVM-NEXT: NoteSection {
# GNU-NEXT: /path/to/libc.so
# GNU-NEXT: 0x0000000000007000 0x0000000000008000 0x0000000000009000
# GNU-NEXT: [stack]
-# GNU-NOT: {{.}}
+# GNU-EMPTY:
# LLVM: Notes [
# LLVM-NEXT: NoteSection {
# CHECK-GNU: Owner Data size Description
# CHECK-GNU-NEXT: CORE 0x00000000 [[DESC]]
+# CHECK-GNU-EMPTY:
# CHECK-LLVM: Note {
# CHECK-LLVM-NEXT: Owner: CORE
// GNU-NEXT: Owner Data size Description
// GNU-NEXT: FreeBSD 0x00000000 NT_THRMISC (thrmisc structure)
// GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_PROC (proc data)
+// GNU-EMPTY:
// GNU-NEXT: Displaying notes found in: .note.bar
// GNU-NEXT: Owner Data size Description
// GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_FILES (files data)
+// GNU-EMPTY:
// 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
+// GNU-EMPTY:
// LLVM: Notes [
// LLVM-NEXT: NoteSection {
// REQUIRES: x86-registered-target
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
-// RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
-// RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+// RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM --strict-whitespace
+// RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU --strict-whitespace
-// GNU: Displaying notes found in: .note.version
-// GNU-NEXT: Owner Data size Description
-// GNU-NEXT: XYZ 0x00000000 NT_VERSION (version)
-
-// GNU: Displaying notes found in: .note.arch
-// GNU-NEXT: Owner Data size Description
-// GNU-NEXT: XYZ 0x00000000 NT_ARCH (architecture)
-
-// GNU: Displaying notes found in: .note.open
-// GNU-NEXT: Owner Data size Description
-// GNU-NEXT: XYZ 0x00000000 OPEN
-
-// GNU: Displaying notes found in: .note.func
-// GNU-NEXT: Owner Data size Description
-// GNU-NEXT: XYZ 0x00000000 func
+// GNU: Displaying notes found in: .note.version{{$}}
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: XYZ 0x00000000 NT_VERSION (version)
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found in: .note.arch{{$}}
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: XYZ 0x00000000 NT_ARCH (architecture)
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found in: .note.open{{$}}
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: XYZ 0x00000000 OPEN
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found in: .note.func{{$}}
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: XYZ 0x00000000 func
// LLVM: Notes [
// LLVM-NEXT: NoteSection {
// GNU: Displaying notes found in: .note.foo
// GNU-NEXT: Owner Data size Description
// GNU-NEXT: XYZ 0x00000000 Unknown note type: (0x00000003)
+// GNU-EMPTY:
// 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
+// GNU-EMPTY:
// LLVM: Notes [
// LLVM-NEXT: NoteSection {
}
template <class ELFT> void GNUELFDumper<ELFT>::printNotes() {
+ bool IsFirstHeader = true;
auto PrintHeader = [&](Optional<StringRef> SecName,
const typename ELFT::Off Offset,
const typename ELFT::Addr Size) {
+ // Print a newline between notes sections to match GNU readelf.
+ if (!IsFirstHeader) {
+ OS << '\n';
+ } else {
+ IsFirstHeader = false;
+ }
+
OS << "Displaying notes found ";
if (SecName)