[lld] [llvm] [llvm-readobj][ELF] Alter JSON/LLVM output on note sections to allow for multiple notes per section in JSON (PR #96813)

Fred Grim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 05:45:48 PDT 2024


https://github.com/feg208 updated https://github.com/llvm/llvm-project/pull/96813

>From 07a1c945c40258d40397690f06edea1950c9a468 Mon Sep 17 00:00:00 2001
From: Fred Grim <fgrim at apple.com>
Date: Wed, 26 Jun 2024 09:26:15 -0700
Subject: [PATCH 1/2] [llvm-readobj][ELF] Alter JSON/LLVM output on note
 sections to allow for multiple notes per section in JSON

It turns out that the notes section for corefiles (or really any elf
file with multiple notes) is set up in such a way for LLVM formatted
output that the JSON equivalent only has the last note since the notes
are held in a dictionary with every key being Note. This pr alters the
layout for the notes to a list of dictionaries to sidestep this issue
for JSON output. Prior to this pr a note section in the output looked
like (for LLVM output):

```
Notes [
  NoteSection {
    Name: <?>
    Offset: 0x2148
    Size: 0x1F864
    Note {
      Owner: CORE
      Data size: 0x150
      Type: NT_PRSTATUS (prstatus structure)
      Description data (
        0000: 06000000 00000000 00000000 06000000  |................|
        ...
      )
    }
    Note {
      Owner: CORE
      Data size: 0x88
      Type: NT_PRPSINFO (prpsinfo structure)
      Description data (
        0000: 02440000 00000000 04054040 00000000  |.D........@@....|
	....
```

But is now:

```
Notes [
  NoteSection {
    Name: <?>
    Offset: 0x2148
    Size: 0x1F864
    Notes [
      {
        Owner: CORE
        Data size: 0x150
        Type: NT_PRSTATUS (prstatus structure)
        Description data (
          0000: 06000000 00000000 00000000 06000000  |................|
          ...
        )
      }
      {
        Owner: CORE
        Data size: 0x88
        Type: NT_PRPSINFO (prpsinfo structure)
        Description data (
          0000: 02440000 00000000 04054040 00000000  |.D........@@....|
	  ...
```
---
 lld/test/ELF/gnu-property-align-32.s          |   4 +-
 lld/test/ELF/gnu-property-align.s             |   4 +-
 lld/test/ELF/partition-notes.s                |   8 +-
 .../tools/llvm-readobj/ELF/gnu-note-size.test |   4 +-
 .../tools/llvm-readobj/ELF/gnu-notes.test     |  28 +++-
 .../llvm-readobj/ELF/note-amd-invalid-v2.test |  36 +++--
 .../llvm-readobj/ELF/note-amd-invalid-v3.test |   4 +-
 .../llvm-readobj/ELF/note-amd-valid-v2.test   |  32 +++--
 llvm/test/tools/llvm-readobj/ELF/note-amd.s   |  20 ++-
 .../llvm-readobj/ELF/note-amdgpu-invalid.s    |  10 +-
 .../tools/llvm-readobj/ELF/note-amdgpu.test   |   8 +-
 .../ELF/note-core-multiple-sections.test      |  39 ++++++
 .../llvm-readobj/ELF/note-core-ntfile.test    | 104 +++++++-------
 .../tools/llvm-readobj/ELF/note-core.test     |   6 +-
 .../llvm-readobj/ELF/note-freebsd-core.test   | 130 +++++++++---------
 .../tools/llvm-readobj/ELF/note-freebsd.test  | 118 ++++++++--------
 .../tools/llvm-readobj/ELF/note-generic.s     |  48 ++++---
 .../llvm-readobj/ELF/note-gnu-property.s      |  50 +++----
 .../llvm-readobj/ELF/note-gnu-property2.s     |  18 +--
 .../llvm-readobj/ELF/note-llvmompoffload.test |  38 ++---
 .../llvm-readobj/ELF/note-netbsd-core.test    |  32 +++--
 .../llvm-readobj/ELF/note-openbsd-core.test   |  52 +++----
 .../tools/llvm-readobj/ELF/note-unknown.s     |  66 +++++----
 llvm/tools/llvm-readobj/ELFDumper.cpp         |  13 +-
 24 files changed, 516 insertions(+), 356 deletions(-)
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/note-core-multiple-sections.test

diff --git a/lld/test/ELF/gnu-property-align-32.s b/lld/test/ELF/gnu-property-align-32.s
index 8022a49d34c6c..a6f2bdb5518ad 100644
--- a/lld/test/ELF/gnu-property-align-32.s
+++ b/lld/test/ELF/gnu-property-align-32.s
@@ -17,7 +17,9 @@
 # CHECK-NEXT: Info: 0
 # CHECK-NEXT: AddressAlignment: 4
 
-# CHECK:      Note {
+# CHECK:	  Size: 0x1C
+# CHECK-NEXT: Notes [
+# CHECK-NEXT: {
 # CHECK-NEXT:   Owner: GNU
 # CHECK-NEXT:   Data size: 0xC
 # CHECK-NEXT:   Type: NT_GNU_PROPERTY_TYPE_0 (property note)
diff --git a/lld/test/ELF/gnu-property-align.s b/lld/test/ELF/gnu-property-align.s
index b109c09039a2c..8c89f44f37f3a 100644
--- a/lld/test/ELF/gnu-property-align.s
+++ b/lld/test/ELF/gnu-property-align.s
@@ -17,7 +17,9 @@
 # CHECK-NEXT: Info: 0
 # CHECK-NEXT: AddressAlignment: 8
 
-# CHECK:      Note {
+# CHECK:	  Size: 0x20
+# CHECK-NEXT: Notes [
+# CHECK-NEXT: {
 # CHECK-NEXT:   Owner: GNU
 # CHECK-NEXT:   Data size: 0x10
 # CHECK-NEXT:   Type: NT_GNU_PROPERTY_TYPE_0 (property note)
diff --git a/lld/test/ELF/partition-notes.s b/lld/test/ELF/partition-notes.s
index c5ade3a47e052..37b6cde62539d 100644
--- a/lld/test/ELF/partition-notes.s
+++ b/lld/test/ELF/partition-notes.s
@@ -20,7 +20,8 @@
 // CHECK-NEXT:     Name: .note.obj
 // CHECK-NEXT:     Offset: 0x{{0*}}[[NOTE_OFFSET]]
 // CHECK-NEXT:     Size:
-// CHECK-NEXT:     Note {
+// CHECK-NEXT:	   Notes [
+// CHECK-NEXT:     {
 // CHECK-NEXT:       Owner: foo
 // CHECK-NEXT:       Data size: 0x4
 // CHECK-NEXT:       Type: NT_VERSION (version)
@@ -28,17 +29,20 @@
 // CHECK-NEXT:         0000: 62617200                             |bar.|
 // CHECK-NEXT:       )
 // 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:	   Notes [
+// CHECK-NEXT:     {
 // CHECK-NEXT:       Owner: GNU
 // CHECK-NEXT:       Data size:
 // CHECK-NEXT:       Type: NT_GNU_BUILD_ID (unique build ID bitstring)
 // CHECK-NEXT:       Build ID: d5101cb9d03b7e836ba9b64f5768a0b31980920f{{$}}
 // CHECK-NEXT:     }
+// CHECK-NEXT:	  ]
 // CHECK-NEXT:   }
 // CHECK-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test b/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test
index 2f131a6cb347b..a78b8b318ec17 100644
--- a/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test
+++ b/llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test
@@ -16,7 +16,8 @@
 # LLVM-NEXT:     Name: .note.ABI-tag
 # LLVM-NEXT:     Offset:
 # LLVM-NEXT:     Size: 0x14
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: GNU
 # LLVM-NEXT:       Data size: 0x4
 # LLVM-NEXT:       Type: NT_GNU_ABI_TAG (ABI version tag)
@@ -25,6 +26,7 @@
 # LLVM-NEXT:         0000: 00000000 |....|
 # LLVM-NEXT:       )
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
index e73238e6093a8..739cdd1da76c4 100644
--- a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
+++ b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
@@ -33,41 +33,48 @@
 # LLVM-NEXT:     Name: .note.ABI-tag
 # LLVM-NEXT:     Offset: 0x78
 # LLVM-NEXT:     Size: 0x20
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: GNU
 # LLVM-NEXT:       Data size: 0x10
 # LLVM-NEXT:       Type: NT_GNU_ABI_TAG (ABI version tag)
 # LLVM-NEXT:       OS: Linux
 # LLVM-NEXT:       ABI: 2.6.32
 # LLVM-NEXT:     }
+# 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 {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: GNU
 # LLVM-NEXT:       Data size: 0x10
 # LLVM-NEXT:       Type: NT_GNU_BUILD_ID (unique build ID bitstring)
 # LLVM-NEXT:       Build ID: 4fcb712aa6387724a9f465a32cd8c14b
 # LLVM-NEXT:     }
+# 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 {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: GNU
 # LLVM-NEXT:       Data size: 0x9
 # LLVM-NEXT:       Type: NT_GNU_GOLD_VERSION (gold version)
 # LLVM-NEXT:       Version: gold 1.11
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.gnu.unknown
 # LLVM-NEXT:     Offset: 0xD4
 # LLVM-NEXT:     Size: 0x14
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: GNU
 # LLVM-NEXT:       Data size: 0x4
 # LLVM-NEXT:       Type: Unknown (0x0000abcd)
@@ -75,6 +82,7 @@
 # LLVM-NEXT:         0000: 61626364                             |abcd|
 # LLVM-NEXT:       )
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
@@ -84,12 +92,14 @@
 # LLVM-STRIPPED-NEXT:     Name: <?>
 # LLVM-STRIPPED-NEXT:     Offset: 0x78
 # LLVM-STRIPPED-NEXT:     Size: 0x20
-# LLVM-STRIPPED-NEXT:     Note {
+# LLVM-STRIPPED-NEXT:     Notes [
+# LLVM-STRIPPED-NEXT:     {
 # 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:   }
 # LLVM-STRIPPED-NEXT: ]
 
@@ -149,7 +159,9 @@ ProgramHeaders:
 # ERR1-LLVM-NEXT:     Name:   .note
 # ERR1-LLVM-NEXT:     Offset: 0xFFFF0000
 # ERR1-LLVM-NEXT:     Size:   0x0
+# ERR1-LLVM-NEXT:     Notes [
 # ERR1-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)
+# ERR1-LLVM-NEXT:    ]
 # ERR1-LLVM-NEXT:   }
 # ERR1-LLVM-NEXT: ]
 
@@ -182,7 +194,9 @@ Sections:
 # ERR2-LLVM-NEXT:     Name: .note
 # ERR2-LLVM-NEXT:     Offset: 0x40
 # ERR2-LLVM-NEXT:     Size: 0xFFFF0000
+# ERR2-LLVM-NEXT:     Notes [
 # ERR2-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)
+# ERR2-LLVM-NEXT:    ]
 # ERR2-LLVM-NEXT:   }
 # ERR2-LLVM-NEXT: ]
 
@@ -203,7 +217,9 @@ Sections:
 # ERR3-LLVM-NEXT:     Name: <?>
 # ERR3-LLVM-NEXT:     Offset: 0xFFFF0000
 # ERR3-LLVM-NEXT:     Size: 0x0
+# ERR3-LLVM-NEXT:     Notes [
 # ERR3-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0xffff0000) or size (0x0)
+# ERR3-LLVM-NEXT:    ]
 # ERR3-LLVM-NEXT:   }
 # ERR3-LLVM-NEXT: ]
 
@@ -234,7 +250,9 @@ ProgramHeaders:
 # ERR4-LLVM-NEXT:     Name: <?>
 # ERR4-LLVM-NEXT:     Offset: 0x0
 # ERR4-LLVM-NEXT:     Size: 0xFFFF0000
+# ERR4-LLVM-NEXT:     Notes [
 # ERR4-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0x0) or size (0xffff0000)
+# ERR4-LLVM-NEXT:    ]
 # ERR4-LLVM-NEXT:   }
 # ERR4-LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v2.test b/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v2.test
index 778724b8ab6ce..2f281ad509bb9 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v2.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v2.test
@@ -10,100 +10,118 @@
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_code_object_version_0
 # LLVM-NEXT:     Offset: 0x40
 # LLVM-NEXT:     Size: 0x14
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x4
 # LLVM-NEXT:       Type: NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
 # LLVM-NEXT:       AMD HSA Code Object Version: Invalid AMD HSA Code Object Version
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_code_object_version_1
 # LLVM-NEXT:     Offset: 0x54
 # LLVM-NEXT:     Size: 0x1C
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0xC
 # LLVM-NEXT:       Type: NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
 # LLVM-NEXT:       AMD HSA Code Object Version: Invalid AMD HSA Code Object Version
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_hsail_0
 # LLVM-NEXT:     Offset: 0x70
 # LLVM-NEXT:     Size: 0x1C
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0xA
 # LLVM-NEXT:       Type: NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
 # LLVM-NEXT:       AMD HSA HSAIL Properties: Invalid AMD HSA HSAIL Properties
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_hsail_1
 # LLVM-NEXT:     Offset: 0x8C
 # LLVM-NEXT:     Size: 0x24
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x14
 # LLVM-NEXT:       Type: NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
 # LLVM-NEXT:       AMD HSA HSAIL Properties: Invalid AMD HSA HSAIL Properties
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_0
 # LLVM-NEXT:     Offset: 0xB0
 # LLVM-NEXT:     Size: 0x18
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x8
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
 # LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_1
 # LLVM-NEXT:     Offset: 0xC8
 # LLVM-NEXT:     Size: 0x28
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x17
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
 # LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_2
 # LLVM-NEXT:     Offset: 0xF0
 # LLVM-NEXT:     Size: 0x28
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x17
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
 # LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_3
 # LLVM-NEXT:     Offset: 0x118
 # LLVM-NEXT:     Size: 0x28
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x17
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
 # LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_pal_metadata
 # LLVM-NEXT:     Offset: 0x140
 # LLVM-NEXT:     Size: 0x14
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x4
 # LLVM-NEXT:       Type: NT_AMD_PAL_METADATA (AMD PAL Metadata)
 # LLVM-NEXT:       AMD PAL Metadata: Invalid AMD PAL Metadata
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v3.test b/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v3.test
index dd090b9483e29..52348b6559e2d 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v3.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-amd-invalid-v3.test
@@ -10,7 +10,8 @@
 # LLVM-NEXT:      Name: .note.nt_amdgpu_metadata
 # LLVM-NEXT:      Offset: 0x40
 # LLVM-NEXT:      Size: 0x38
-# LLVM-NEXT:      Note {
+# LLVM-NEXT:      Notes [
+# LLVM-NEXT:      {
 # LLVM-NEXT:        Owner: AMDGPU
 # LLVM-NEXT:        Data size: 0x24
 # LLVM-NEXT:        Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
@@ -21,6 +22,7 @@
 # LLVM-NEXT:  ...
 # LLVM-EMPTY:
 # LLVM-NEXT:      }
+# LLVM-NEXT:     ]
 # LLVM-NEXT:    }
 # LLVM-NEXT:  ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test b/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test
index 3af1bb2acafdf..adfd61f2b4923 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test
@@ -10,89 +10,105 @@
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_code_object_version
 # LLVM-NEXT:     Offset: 0x40
 # LLVM-NEXT:     Size: 0x18
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x8
 # LLVM-NEXT:       Type: NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
 # LLVM-NEXT:       AMD HSA Code Object Version: [Major: 2, Minor: 1]
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_hsail
 # LLVM-NEXT:     Offset: 0x58
 # LLVM-NEXT:     Size: 0x1C
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0xC
 # LLVM-NEXT:       Type: NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
 # LLVM-NEXT:       AMD HSA HSAIL Properties: [HSAIL Major: 2, HSAIL Minor: 1, Profile: 1, Machine Model: 2, Default Float Round: 3]
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version
 # LLVM-NEXT:     Offset: 0x74
 # LLVM-NEXT:     Size: 0x2C
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x1B
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
 # LLVM-NEXT:       AMD HSA ISA Version: [Vendor: AMD, Architecture: AMDGPU, Major: 8, Minor: 0, Stepping: 2]
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_metadata_0
 # LLVM-NEXT:     Offset: 0xA0
 # LLVM-NEXT:     Size: 0x10
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x0
 # LLVM-NEXT:       Type: NT_AMD_HSA_METADATA (AMD HSA Metadata)
 # LLVM-NEXT:       AMD HSA Metadata:
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_metadata_1
 # LLVM-NEXT:     Offset: 0xB0
 # LLVM-NEXT:     Size: 0x18
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x6
 # LLVM-NEXT:       Type: NT_AMD_HSA_METADATA (AMD HSA Metadata)
 # LLVM-NEXT:       AMD HSA Metadata: abcde
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_name_0
 # LLVM-NEXT:     Offset: 0xC8
 # LLVM-NEXT:     Size: 0x10
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x0
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_NAME (AMD HSA ISA Name)
 # LLVM-NEXT:       AMD HSA ISA Name:
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_name_1
 # LLVM-NEXT:     Offset: 0xD8
 # LLVM-NEXT:     Size: 0x18
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x6
 # LLVM-NEXT:       Type: NT_AMD_HSA_ISA_NAME (AMD HSA ISA Name)
 # LLVM-NEXT:       AMD HSA ISA Name: abcdef
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.nt_amd_pal_metadata
 # LLVM-NEXT:     Offset: 0xF0
 # LLVM-NEXT:     Size: 0x28
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMD
 # LLVM-NEXT:       Data size: 0x18
 # LLVM-NEXT:       Type: NT_AMD_PAL_METADATA (AMD PAL Metadata)
 # LLVM-NEXT:       AMD PAL Metadata: [2: 1][4: 2][8: 4]
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amd.s b/llvm/test/tools/llvm-readobj/ELF/note-amd.s
index 260be3a725af7..153b224578e9b 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-amd.s
+++ b/llvm/test/tools/llvm-readobj/ELF/note-amd.s
@@ -39,52 +39,59 @@
 // LLVM-NEXT:     Name: .note.no.desc
 // LLVM-NEXT:     Offset:
 // LLVM-NEXT:     Size:
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: AMD
 // LLVM-NEXT:       Data size: 0x0
 // LLVM-NEXT:       Type: NT_AMD_HSA_METADATA (AMD HSA Metadata)
 // LLVM-NEXT:       AMD HSA Metadata:
 // LLVM-NEXT:     }
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: AMD
 // LLVM-NEXT:       Data size: 0x0
 // LLVM-NEXT:       Type: NT_AMD_HSA_ISA_NAME (AMD HSA ISA Name)
 // LLVM-NEXT:       AMD HSA ISA Name:
 // LLVM-NEXT:     }
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.desc
 // LLVM-NEXT:     Offset:
 // LLVM-NEXT:     Size:
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: AMD
 // LLVM-NEXT:       Data size: 0xA
 // LLVM-NEXT:       Type: NT_AMD_HSA_METADATA (AMD HSA Metadata)
 // LLVM-NEXT:       AMD HSA Metadata: meta_blah
 // LLVM-NEXT:     }
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: AMD
 // LLVM-NEXT:       Data size: 0x9
 // LLVM-NEXT:       Type: NT_AMD_HSA_ISA_NAME (AMD HSA ISA Name)
 // LLVM-NEXT:       AMD HSA ISA Name: isa_blah
 // LLVM-NEXT:     }
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.other
 // LLVM-NEXT:     Offset:
 // LLVM-NEXT:     Size:
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: AMD
 // LLVM-NEXT:       Data size: 0x0
 // LLVM-NEXT:       Type: NT_AMD_PAL_METADATA (AMD PAL Metadata)
 // LLVM-NEXT:       AMD PAL Metadata:
 // LLVM-NEXT:     }
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.unknown
 // LLVM-NEXT:     Offset:
 // LLVM-NEXT:     Size:
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: AMD
 // LLVM-NEXT:       Data size: 0x7
 // LLVM-NEXT:       Type: Unknown (0x000004d2)
@@ -92,6 +99,7 @@
 // LLVM-NEXT:         0000: 61626364 656600                      |abcdef.|
 // LLVM-NEXT:       )
 // LLVM-NEXT:     }
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amdgpu-invalid.s b/llvm/test/tools/llvm-readobj/ELF/note-amdgpu-invalid.s
index 0ed791c30954e..97815ef356a8e 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-amdgpu-invalid.s
+++ b/llvm/test/tools/llvm-readobj/ELF/note-amdgpu-invalid.s
@@ -35,7 +35,8 @@
 # LLVM-NEXT:     Name: .note.foo
 # LLVM-NEXT:     Offset: 0x40
 # LLVM-NEXT:     Size: 0xE8
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:	 Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMDGPU
 # LLVM-NEXT:       Data size: 0xD4
 # LLVM-NEXT:       Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
@@ -55,12 +56,14 @@
 # LLVM-NEXT: ...
 # LLVM-EMPTY:
 # LLVM-NEXT:     }
+# LLVM-NEXT:	]
 # LLVM-NEXT:   }
 # LLVM-NEXT:  NoteSection {
 # LLVM-NEXT:    Name: .note.bar
 # LLVM-NEXT:    Offset: 0x128
 # LLVM-NEXT:    Size: 0x30
-# LLVM-NEXT:    Note {
+# LLVM-NEXT:	Notes [
+# LLVM-NEXT:    {
 # LLVM-NEXT:      Owner: AMDGPU
 # LLVM-NEXT:      Data size: 0x3
 # LLVM-NEXT:      Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
@@ -68,7 +71,7 @@
 # LLVM-NEXT:        0000: 123456                               |.4V|
 # LLVM-NEXT:      )
 # LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
+# LLVM-NEXT:    {
 # LLVM-NEXT:      Owner: AMDGPU
 # LLVM-NEXT:      Data size: 0x3
 # LLVM-NEXT:      Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
@@ -76,6 +79,7 @@
 # LLVM-NEXT:        0000: ABCDEF                               |...|
 # LLVM-NEXT:      )
 # LLVM-NEXT:    }
+# LLVM-NEXT:   ]
 # LLVM-NEXT:  }
 # LLVM-NEXT:]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test b/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test
index 5d4f41ced9b16..97156b1a2fbc1 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test
@@ -36,7 +36,8 @@
 # LLVM-NEXT:     Name: .note.foo
 # LLVM-NEXT:     Offset:
 # LLVM-NEXT:     Size:
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMDGPU
 # LLVM-NEXT:       Data size: 0xFB
 # LLVM-NEXT:       Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
@@ -59,12 +60,14 @@
 # LLVM-NEXT: ...
 # LLVM-EMPTY:
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: .note.unknown
 # LLVM-NEXT:     Offset: 0x150
 # LLVM-NEXT:     Size: 0x18
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: AMDGPU
 # LLVM-NEXT:       Data size: 0x2
 # LLVM-NEXT:       Type: Unknown (0x00000101)
@@ -72,6 +75,7 @@
 # LLVM-NEXT:         0000: ABCD                                 |..|
 # LLVM-NEXT:       )
 # LLVM-NEXT:     }
+# LLVM-NEXT:     ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-core-multiple-sections.test b/llvm/test/tools/llvm-readobj/ELF/note-core-multiple-sections.test
new file mode 100644
index 0000000000000..8593aee003816
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/note-core-multiple-sections.test
@@ -0,0 +1,39 @@
+## Test that note values are interpreted correctly for core files with multiple sections.
+
+## Check NT_PRSTATUS + NT_PRPSINFO.
+# RUN: yaml2obj %s -DTYPE1=0x1 -DTYPE2=0x3 -o %t1.o
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --notes %t1.o | FileCheck %s --check-prefix=CHECK-JSON  -DDESC1="NT_PRSTATUS (prstatus structure)" -DDESC2="NT_PRPSINFO (prpsinfo structure)"
+# CHECK-JSON:       "Size": 40,
+# CHECK-JSON-NEXT:  "Notes": [
+# CHECK-JSON-NEXT:  {
+# CHECK-JSON-NEXT:   "Owner": "CORE",
+# CHECK-JSON-NEXT:   "Data size": 0,
+# CHECK-JSON-NEXT:   "Type": "[[DESC1]]"
+# CHECK-JSON-NEXT:  },
+# CHECK-JSON-NEXT:  {
+# CHECK-JSON-NEXT:   "Owner": "CORE",
+# CHECK-JSON-NEXT:   "Data size": 0,
+# CHECK-JSON-NEXT:   "Type": "[[DESC2]]"
+# CHECK-JSON-NEXT:  }
+# CHECK-JSON-NEXT:  ]
+
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_CORE
+Sections:
+  - Name: .note.first
+    Type: SHT_NOTE
+    Notes:
+      - Name: CORE
+        Type: [[TYPE1]]
+  - Name: .note.second
+    Type: SHT_NOTE
+    Notes:
+      - Name: CORE
+        Type: [[TYPE2]]
+ProgramHeaders:
+  - Type:     PT_NOTE
+    FirstSec: .note.first
+    LastSec:  .note.second
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test b/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test
index f4957b42a8778..ee5128d6a4b62 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test
@@ -68,32 +68,34 @@ ProgramHeaders:
 # LLVM-NEXT:     Name: <?>
 # LLVM-NEXT:     Offset:
 # LLVM-NEXT:     Size:
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: CORE
-# LLVM-NEXT:       Data size: 0x80
-# LLVM-NEXT:       Type: NT_FILE (mapped files)
-# LLVM-NEXT:       Page Size: 4096
-# LLVM-NEXT:       Mappings [
+# LLVM-NEXT:     Notes [
 # LLVM-NEXT:        {
-# LLVM-NEXT:         Start: 0x1000
-# LLVM-NEXT:         End: 0x2000
-# LLVM-NEXT:         Offset: 0x3000
-# LLVM-NEXT:         Filename: /path/to/a.out
+# LLVM-NEXT:            Owner: CORE
+# LLVM-NEXT:            Data size: 0x80
+# LLVM-NEXT:            Type: NT_FILE (mapped files)
+# LLVM-NEXT:            Page Size: 4096
+# LLVM-NEXT:            Mappings [
+# LLVM-NEXT:                {
+# LLVM-NEXT:                    Start: 0x1000
+# LLVM-NEXT:                    End: 0x2000
+# LLVM-NEXT:                    Offset: 0x3000
+# LLVM-NEXT:                    Filename: /path/to/a.out
+# LLVM-NEXT:                }
+# LLVM-NEXT:                {
+# LLVM-NEXT:                    Start: 0x4000
+# LLVM-NEXT:                    End: 0x5000
+# LLVM-NEXT:                    Offset: 0x6000
+# LLVM-NEXT:                    Filename: /path/to/libc.so
+# LLVM-NEXT:                }
+# LLVM-NEXT:                {
+# LLVM-NEXT:                    Start: 0x7000
+# LLVM-NEXT:                    End: 0x8000
+# LLVM-NEXT:                    Offset: 0x9000
+# LLVM-NEXT:                    Filename: [stack]
+# LLVM-NEXT:                }
+# LLVM-NEXT:            ]
 # LLVM-NEXT:        }
-# LLVM-NEXT:        {
-# LLVM-NEXT:         Start: 0x4000
-# LLVM-NEXT:         End: 0x5000
-# LLVM-NEXT:         Offset: 0x6000
-# LLVM-NEXT:         Filename: /path/to/libc.so
-# LLVM-NEXT:        }
-# LLVM-NEXT:        {
-# LLVM-NEXT:         Start: 0x7000
-# LLVM-NEXT:         End: 0x8000
-# LLVM-NEXT:         Offset: 0x9000
-# LLVM-NEXT:         Filename: [stack]
-# LLVM-NEXT:       }
-# LLVM-NEXT:     ]
-# LLVM-NEXT:   }
+# LLVM-NEXT:    ]
 # LLVM-NEXT: }
 # LLVM-NEXT: ]
 
@@ -103,32 +105,34 @@ ProgramHeaders:
 # JSON-NEXT:          "Name": "<?>",
 # JSON-NEXT:          "Offset": 120,
 # JSON-NEXT:          "Size": 148,
-# JSON-NEXT:          "Note": {
-# JSON-NEXT:              "Owner": "CORE",
-# JSON-NEXT:              "Data size": 128,
-# JSON-NEXT:              "Type": "NT_FILE (mapped files)",
-# JSON-NEXT:              "Page Size": 4096,
-# JSON-NEXT:              "Mappings": [
-# JSON-NEXT:                {
-# JSON-NEXT:                  "Start": 4096,
-# JSON-NEXT:                  "End": 8192,
-# JSON-NEXT:                  "Offset": 12288,
-# JSON-NEXT:                  "Filename": "/path/to/a.out"
-# JSON-NEXT:                },
-# JSON-NEXT:                {
-# JSON-NEXT:                  "Start": 16384,
-# JSON-NEXT:                  "End": 20480,
-# JSON-NEXT:                  "Offset": 24576,
-# JSON-NEXT:                  "Filename": "/path/to/libc.so"
-# JSON-NEXT:                },
-# JSON-NEXT:                {
-# JSON-NEXT:                  "Start": 28672,
-# JSON-NEXT:                  "End": 32768,
-# JSON-NEXT:                  "Offset": 36864,
-# JSON-NEXT:                  "Filename": "[stack]"
-# JSON-NEXT:                }
-# JSON-NEXT:            ]
-# JSON-NEXT:          }
+# JSON-NEXT:          "Notes": [
+# JSON-NEXT:            {
+# JSON-NEXT:                "Owner": "CORE",
+# JSON-NEXT:                "Data size": 128,
+# JSON-NEXT:                "Type": "NT_FILE (mapped files)",
+# JSON-NEXT:                "Page Size": 4096,
+# JSON-NEXT:                "Mappings": [
+# JSON-NEXT:                    {
+# JSON-NEXT:                        "Start": 4096,
+# JSON-NEXT:                        "End": 8192,
+# JSON-NEXT:                        "Offset": 12288,
+# JSON-NEXT:                        "Filename": "/path/to/a.out"
+# JSON-NEXT:                    },
+# JSON-NEXT:                    {
+# JSON-NEXT:                        "Start": 16384,
+# JSON-NEXT:                        "End": 20480,
+# JSON-NEXT:                        "Offset": 24576,
+# JSON-NEXT:                        "Filename": "/path/to/libc.so"
+# JSON-NEXT:                    },
+# JSON-NEXT:                    {
+# JSON-NEXT:                        "Start": 28672,
+# JSON-NEXT:                        "End": 32768,
+# JSON-NEXT:                        "Offset": 36864,
+# JSON-NEXT:                        "Filename": "[stack]"
+# JSON-NEXT:                    }
+# JSON-NEXT:                ]
+# JSON-NEXT:            }
+# JSON-NEXT:        ]
 # JSON-NEXT:      }
 # JSON-NEXT: }
 # JSON-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-core.test b/llvm/test/tools/llvm-readobj/ELF/note-core.test
index 84ec96b1702a9..484638e05d512 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-core.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-core.test
@@ -284,11 +284,13 @@
 # CHECK-GNU-NEXT: CORE  0x00000000 [[DESC]]
 # CHECK-GNU-EMPTY:
 
-# CHECK-LLVM:      Note {
+# CHECK-LLVM:       Size: 0x14
+# CHECK-LLVM-NEXT:  Notes: [
+# CHECK-LLVM-NEXT:  {
 # CHECK-LLVM-NEXT:   Owner: CORE
 # CHECK-LLVM-NEXT:   Data size: 0x0
 # CHECK-LLVM-NEXT:   Type: [[DESC]]
-# CHECK-LLVM-NEXT: }
+# CHECK-LLVM-NEXT:  }
 
 --- !ELF
 FileHeader:
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-freebsd-core.test b/llvm/test/tools/llvm-readobj/ELF/note-freebsd-core.test
index 438c278de68ad..d254aac02ebc3 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-freebsd-core.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-freebsd-core.test
@@ -73,73 +73,77 @@ ProgramHeaders:
 # LLVM-NEXT:     Name: <?>
 # LLVM-NEXT:     Offset: 0xB0
 # LLVM-NEXT:     Size: 0xDC
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_THRMISC (thrmisc structure)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_PROC (proc data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_FILES (files data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_VMMAP (vmmap data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_GROUPS (groups data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_UMASK (umask data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_RLIMIT (rlimit data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_OSREL (osreldate data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_PSSTRINGS (ps_strings data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_PROCSTAT_AUXV (auxv data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: Unknown (0x00012345)
-# LLVM-NEXT:     }
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_THRMISC (thrmisc structure)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_PROC (proc data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_FILES (files data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_VMMAP (vmmap data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_GROUPS (groups data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_UMASK (umask data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_RLIMIT (rlimit data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_OSREL (osreldate data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_PSSTRINGS (ps_strings data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_PROCSTAT_AUXV (auxv data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: Unknown (0x00012345)
+# LLVM-NEXT:        }
+# LLVM-NEXT:     ]
 # LLVM-NEXT:   }
 # LLVM-NEXT:   NoteSection {
 # LLVM-NEXT:     Name: <?>
 # LLVM-NEXT:     Offset: 0x18C
 # LLVM-NEXT:     Size: 0x1C
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: FreeBSD
-# LLVM-NEXT:       Data size: 0x6
-# LLVM-NEXT:       Type: NT_PRPSINFO (prpsinfo structure)
-# LLVM-NEXT:       Description data (
-# LLVM-NEXT:         0000: AABBCCDD EEFF                        |......|
-# LLVM-NEXT:       )
-# LLVM-NEXT:     }
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x6
+# LLVM-NEXT:            Type: NT_PRPSINFO (prpsinfo structure)
+# LLVM-NEXT:            Description data (
+# LLVM-NEXT:                0000: AABBCCDD EEFF                        |......|
+# LLVM-NEXT:        )
+# LLVM-NEXT:        }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-freebsd.test b/llvm/test/tools/llvm-readobj/ELF/note-freebsd.test
index 937cb6f426b1a..1643c654f7157 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-freebsd.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-freebsd.test
@@ -66,63 +66,65 @@ Sections:
 # LLVM-NEXT:    Name: .note.tag
 # LLVM-NEXT:    Offset: 0x40
 # LLVM-NEXT:    Size: 0xCC
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x4
-# LLVM-NEXT:      Type: NT_FREEBSD_ABI_TAG (ABI version tag)
-# LLVM-NEXT:      ABI tag: 1300076
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x1
-# LLVM-NEXT:      Type: NT_FREEBSD_ABI_TAG (ABI version tag)
-# LLVM-NEXT:      Description data (
-# LLVM-NEXT:        0000: 6C                                   |l|
-# LLVM-NEXT:      )
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x7
-# LLVM-NEXT:      Type: NT_FREEBSD_ARCH_TAG (architecture tag)
-# LLVM-NEXT:      Arch tag: aarch64
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x4
-# LLVM-NEXT:      Type: NT_FREEBSD_FEATURE_CTL (FreeBSD feature control)
-# LLVM-NEXT:      Feature flags: ASLR_DISABLE PROTMAX_DISABLE STKGAP_DISABLE WXNEEDED LA48 ASG_DISABLE (0xFFFFFFFF)
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x1
-# LLVM-NEXT:      Type: NT_FREEBSD_FEATURE_CTL (FreeBSD feature control)
-# LLVM-NEXT:      Description data (
-# LLVM-NEXT:        0000: 00                                   |.|
-# LLVM-NEXT:      )
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x4
-# LLVM-NEXT:      Type: NT_FREEBSD_NOINIT_TAG (no .init tag)
-# LLVM-NEXT:      Description data (
-# LLVM-NEXT:        0000: 00000000                             |....|
-# LLVM-NEXT:      )
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x6
-# LLVM-NEXT:      Type: Unknown (0x00abcdef)
-# LLVM-NEXT:      Description data (
-# LLVM-NEXT:        0000: 61626364 6566                        |abcdef|
-# LLVM-NEXT:      )
-# LLVM-NEXT:    }
-# LLVM-NEXT:    Note {
-# LLVM-NEXT:      Owner: FreeBSD
-# LLVM-NEXT:      Data size: 0x6
-# LLVM-NEXT:      Type: Unknown (0x0000000d)
-# LLVM-NEXT:      Description data (
-# LLVM-NEXT:        0000: 61626364 6566                        |abcdef|
-# LLVM-NEXT:      )
-# LLVM-NEXT:    }
+# LLVM-NEXT:    Notes [
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x4
+# LLVM-NEXT:            Type: NT_FREEBSD_ABI_TAG (ABI version tag)
+# LLVM-NEXT:            ABI tag: 1300076
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x1
+# LLVM-NEXT:            Type: NT_FREEBSD_ABI_TAG (ABI version tag)
+# LLVM-NEXT:            Description data (
+# LLVM-NEXT:                0000: 6C                                   |l|
+# LLVM-NEXT:            )
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x7
+# LLVM-NEXT:            Type: NT_FREEBSD_ARCH_TAG (architecture tag)
+# LLVM-NEXT:            Arch tag: aarch64
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x4
+# LLVM-NEXT:            Type: NT_FREEBSD_FEATURE_CTL (FreeBSD feature control)
+# LLVM-NEXT:            Feature flags: ASLR_DISABLE PROTMAX_DISABLE STKGAP_DISABLE WXNEEDED LA48 ASG_DISABLE (0xFFFFFFFF)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x1
+# LLVM-NEXT:            Type: NT_FREEBSD_FEATURE_CTL (FreeBSD feature control)
+# LLVM-NEXT:            Description data (
+# LLVM-NEXT:                0000: 00                                   |.|
+# LLVM-NEXT:            )
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x4
+# LLVM-NEXT:            Type: NT_FREEBSD_NOINIT_TAG (no .init tag)
+# LLVM-NEXT:            Description data (
+# LLVM-NEXT:                0000: 00000000                             |....|
+# LLVM-NEXT:            )
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x6
+# LLVM-NEXT:            Type: Unknown (0x00abcdef)
+# LLVM-NEXT:            Description data (
+# LLVM-NEXT:                0000: 61626364 6566                        |abcdef|
+# LLVM-NEXT:            )
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: FreeBSD
+# LLVM-NEXT:            Data size: 0x6
+# LLVM-NEXT:            Type: Unknown (0x0000000d)
+# LLVM-NEXT:            Description data (
+# LLVM-NEXT:                0000: 61626364 6566                        |abcdef|
+# LLVM-NEXT:        )
+# LLVM-NEXT:        }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:  }
 # LLVM-NEXT:]
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-generic.s b/llvm/test/tools/llvm-readobj/ELF/note-generic.s
index 59df75e3ee19c..30d5ed4db39c1 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-generic.s
+++ b/llvm/test/tools/llvm-readobj/ELF/note-generic.s
@@ -25,41 +25,49 @@
 // LLVM-NEXT:     Name: .note.version
 // LLVM-NEXT:     Offset: 0x40
 // LLVM-NEXT:     Size: 0x10
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: XYZ
-// LLVM-NEXT:       Data size: 0x0
-// LLVM-NEXT:       Type: NT_VERSION (version)
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: XYZ
+// LLVM-NEXT:			Data size: 0x0
+// LLVM-NEXT:			Type: NT_VERSION (version)
+// LLVM-NEXT:		}
+// LLVM-NEXT:	  ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.arch
 // LLVM-NEXT:     Offset: 0x50
 // LLVM-NEXT:     Size: 0x10
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: XYZ
-// LLVM-NEXT:       Data size: 0x0
-// LLVM-NEXT:       Type: NT_ARCH (architecture)
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: XYZ
+// LLVM-NEXT:			Data size: 0x0
+// LLVM-NEXT:			Type: NT_ARCH (architecture)
+// LLVM-NEXT:		}
+// LLVM-NEXT:	  ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.open
 // LLVM-NEXT:     Offset: 0x60
 // LLVM-NEXT:     Size: 0x10
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: XYZ
-// LLVM-NEXT:       Data size: 0x0
-// LLVM-NEXT:       Type: OPEN
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: XYZ
+// LLVM-NEXT:			Data size: 0x0
+// LLVM-NEXT:			Type: OPEN
+// LLVM-NEXT:		}
+// LLVM-NEXT:	  ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.func
 // LLVM-NEXT:     Offset: 0x70
 // LLVM-NEXT:     Size: 0x10
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: XYZ
-// LLVM-NEXT:       Data size: 0x0
-// LLVM-NEXT:       Type: func
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: XYZ
+// LLVM-NEXT:			Data size: 0x0
+// LLVM-NEXT:			Type: func
+// LLVM-NEXT:		}
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s
index 2d0d00f606391..4804b2d78e9e3 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s
+++ b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s
@@ -29,30 +29,32 @@
 // LLVM-NEXT:     Name: .note.gnu.property
 // LLVM-NEXT:     Offset: 0x40
 // LLVM-NEXT:     Size: 0xF8
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: GNU
-// LLVM-NEXT:       Data size: 0xE8
-// LLVM-NEXT:       Type: NT_GNU_PROPERTY_TYPE_0 (property note)
-// LLVM-NEXT:       Property [
-// LLVM-NEXT:         stack size: 0x100
-// LLVM-NEXT:         stack size: 0x100
-// LLVM-NEXT:         no copy on protected
-// LLVM-NEXT:         x86 feature: SHSTK
-// LLVM-NEXT:         x86 feature: IBT, SHSTK
-// LLVM-NEXT:         x86 feature: <None>
-// LLVM-NEXT:         x86 feature needed: x86, x87, MMX, XMM, YMM
-// LLVM-NEXT:         x86 feature used: ZMM, FXSR, XSAVE, XSAVEOPT, XSAVEC
-// LLVM-NEXT:         x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
-// LLVM-NEXT:         x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
-// LLVM-NEXT:         <application-specific type 0xfefefefe>
-// LLVM-NEXT:         stack size: <corrupt length: 0x0>
-// LLVM-NEXT:         stack size: <corrupt length: 0x4>
-// LLVM-NEXT:         no copy on protected <corrupt length: 0x1>
-// LLVM-NEXT:         x86 feature: <corrupt length: 0x0>
-// LLVM-NEXT:         x86 feature: IBT, <unknown flags: 0xf000f000>
-// LLVM-NEXT:         <corrupt type (0x2) datasz: 0x1>
-// LLVM-NEXT:       ]
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: GNU
+// LLVM-NEXT:			Data size: 0xE8
+// LLVM-NEXT:			Type: NT_GNU_PROPERTY_TYPE_0 (property note)
+// LLVM-NEXT:			Property [
+// LLVM-NEXT:				stack size: 0x100
+// LLVM-NEXT:				stack size: 0x100
+// LLVM-NEXT:				no copy on protected
+// LLVM-NEXT:				x86 feature: SHSTK
+// LLVM-NEXT:				x86 feature: IBT, SHSTK
+// LLVM-NEXT:				x86 feature: <None>
+// LLVM-NEXT:				x86 feature needed: x86, x87, MMX, XMM, YMM
+// LLVM-NEXT:				x86 feature used: ZMM, FXSR, XSAVE, XSAVEOPT, XSAVEC
+// LLVM-NEXT:				x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
+// LLVM-NEXT:				x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
+// LLVM-NEXT:				<application-specific type 0xfefefefe>
+// LLVM-NEXT:				stack size: <corrupt length: 0x0>
+// LLVM-NEXT:				stack size: <corrupt length: 0x4>
+// LLVM-NEXT:				no copy on protected <corrupt length: 0x1>
+// LLVM-NEXT:				x86 feature: <corrupt length: 0x0>
+// LLVM-NEXT:				x86 feature: IBT, <unknown flags: 0xf000f000>
+// LLVM-NEXT:				<corrupt type (0x2) datasz: 0x1>
+// LLVM-NEXT:			]
+// LLVM-NEXT:		}
+// LLVM-NEXT:	  ]
 // LLVM-NEXT:   }
 // LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s
index 5ac35d45725c0..1e5892378ee19 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s
+++ b/llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s
@@ -13,14 +13,16 @@
 // LLVM-NEXT:     Name: .note.gnu.property
 // LLVM-NEXT:     Offset: 0x40
 // LLVM-NEXT:     Size: 0x18
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: GNU
-// LLVM-NEXT:       Data size: 0x4
-// LLVM-NEXT:       Type: NT_GNU_PROPERTY_TYPE_0 (property note)
-// LLVM-NEXT:       Property [
-// LLVM-NEXT:         <corrupted GNU_PROPERTY_TYPE_0>
-// LLVM-NEXT:       ]
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: GNU
+// LLVM-NEXT:			Data size: 0x4
+// LLVM-NEXT:			Type: NT_GNU_PROPERTY_TYPE_0 (property note)
+// LLVM-NEXT:			Property [
+// LLVM-NEXT:				<corrupted GNU_PROPERTY_TYPE_0>
+// LLVM-NEXT:			]
+// LLVM-NEXT:		}
+// LLVM-NEXT:	  ]
 // LLVM-NEXT:   }
 // LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-llvmompoffload.test b/llvm/test/tools/llvm-readobj/ELF/note-llvmompoffload.test
index 050ef9a3f465c..44ef5dec5e116 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-llvmompoffload.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-llvmompoffload.test
@@ -18,24 +18,26 @@
 # NOTES-NEXT:     Name: .note.openmp
 # NOTES-NEXT:     Offset: {{.*}}
 # NOTES-NEXT:     Size: {{.*}}
-# NOTES-NEXT:     Note {
-# NOTES-NEXT:       Owner: LLVMOMPOFFLOAD
-# NOTES-NEXT:       Data size: 0x3
-# NOTES-NEXT:       Type: NT_LLVM_OPENMP_OFFLOAD_VERSION (image format version)
-# NOTES-NEXT:       Version: 1.0
-# NOTES-NEXT:     }
-# NOTES-NEXT:     Note {
-# NOTES-NEXT:       Owner: LLVMOMPOFFLOAD
-# NOTES-NEXT:       Data size: 0x4
-# NOTES-NEXT:       Type: NT_LLVM_OPENMP_OFFLOAD_PRODUCER (producing toolchain)
-# NOTES-NEXT:       Producer: LLVM
-# NOTES-NEXT:     }
-# NOTES-NEXT:     Note {
-# NOTES-NEXT:       Owner: LLVMOMPOFFLOAD
-# NOTES-NEXT:       Data size: 0x9
-# NOTES-NEXT:       Type: NT_LLVM_OPENMP_OFFLOAD_PRODUCER_VERSION (producing toolchain version)
-# NOTES-NEXT:       Producer version: 13.0.0git
-# NOTES-NEXT:     }
+# NOTES-NEXT:     Notes [
+# NOTES-NEXT:       {
+# NOTES-NEXT:           Owner: LLVMOMPOFFLOAD
+# NOTES-NEXT:           Data size: 0x3
+# NOTES-NEXT:           Type: NT_LLVM_OPENMP_OFFLOAD_VERSION (image format version)
+# NOTES-NEXT:           Version: 1.0
+# NOTES-NEXT:       }
+# NOTES-NEXT:       {
+# NOTES-NEXT:           Owner: LLVMOMPOFFLOAD
+# NOTES-NEXT:           Data size: 0x4
+# NOTES-NEXT:           Type: NT_LLVM_OPENMP_OFFLOAD_PRODUCER (producing toolchain)
+# NOTES-NEXT:           Producer: LLVM
+# NOTES-NEXT:       }
+# NOTES-NEXT:       {
+# NOTES-NEXT:           Owner: LLVMOMPOFFLOAD
+# NOTES-NEXT:           Data size: 0x9
+# NOTES-NEXT:           Type: NT_LLVM_OPENMP_OFFLOAD_PRODUCER_VERSION (producing toolchain version)
+# NOTES-NEXT:           Producer version: 13.0.0git
+# NOTES-NEXT:       }
+# NOTES-NEXT:    ]
 # NOTES-NEXT:   }
 # NOTES-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-netbsd-core.test b/llvm/test/tools/llvm-readobj/ELF/note-netbsd-core.test
index aec85aa513946..2cedca7bff773 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-netbsd-core.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-netbsd-core.test
@@ -35,20 +35,22 @@ ProgramHeaders:
 # LLVM-NEXT:     Name: <?>
 # LLVM-NEXT:     Offset: 0x78
 # LLVM-NEXT:     Size: 0x50
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: NetBSD-CORE
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_NETBSDCORE_PROCINFO (procinfo structure)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: NetBSD-CORE
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_NETBSDCORE_AUXV (ELF auxiliary vector data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: NetBSD-CORE at 3615
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: PT_LWPSTATUS (ptrace_lwpstatus structure)
-# LLVM-NEXT:     }
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: NetBSD-CORE
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_NETBSDCORE_PROCINFO (procinfo structure)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: NetBSD-CORE
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_NETBSDCORE_AUXV (ELF auxiliary vector data)
+# LLVM-NEXT:            }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: NetBSD-CORE at 3615
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: PT_LWPSTATUS (ptrace_lwpstatus structure)
+# LLVM-NEXT:        }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-openbsd-core.test b/llvm/test/tools/llvm-readobj/ELF/note-openbsd-core.test
index 0ccb55a8d6f33..29548c2ed4168 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-openbsd-core.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-openbsd-core.test
@@ -40,30 +40,32 @@ ProgramHeaders:
 # LLVM-NEXT:     Name: <?>
 # LLVM-NEXT:     Offset: 0x78
 # LLVM-NEXT:     Size: 0x74
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: OpenBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_OPENBSD_PROCINFO (procinfo structure)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: OpenBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_OPENBSD_AUXV (ELF auxiliary vector data)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: OpenBSD
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_OPENBSD_WCOOKIE (window cookie)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: OpenBSD at 31337
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_OPENBSD_REGS (regular registers)
-# LLVM-NEXT:     }
-# LLVM-NEXT:     Note {
-# LLVM-NEXT:       Owner: OpenBSD at 31337
-# LLVM-NEXT:       Data size: 0x0
-# LLVM-NEXT:       Type: NT_OPENBSD_FPREGS (floating point registers)
-# LLVM-NEXT:     }
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: OpenBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_OPENBSD_PROCINFO (procinfo structure)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: OpenBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_OPENBSD_AUXV (ELF auxiliary vector data)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: OpenBSD
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_OPENBSD_WCOOKIE (window cookie)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: OpenBSD at 31337
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_OPENBSD_REGS (regular registers)
+# LLVM-NEXT:        }
+# LLVM-NEXT:        {
+# LLVM-NEXT:            Owner: OpenBSD at 31337
+# LLVM-NEXT:            Data size: 0x0
+# LLVM-NEXT:            Type: NT_OPENBSD_FPREGS (floating point registers)
+# LLVM-NEXT:        }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-unknown.s b/llvm/test/tools/llvm-readobj/ELF/note-unknown.s
index aa74b51a3541b..45f498ac79668 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-unknown.s
+++ b/llvm/test/tools/llvm-readobj/ELF/note-unknown.s
@@ -19,46 +19,52 @@
 // LLVM-NEXT:     Name: .note.foo
 // LLVM-NEXT:     Offset: 0x40
 // LLVM-NEXT:     Size: 0x10
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: XYZ
-// LLVM-NEXT:       Data size: 0x0
-// LLVM-NEXT:       Type: Unknown (0x00000003)
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: XYZ
+// LLVM-NEXT:			Data size: 0x0
+// LLVM-NEXT:			Type: Unknown (0x00000003)
+// LLVM-NEXT:		}
+// LLVM-NEXT:	  ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.bar
 // LLVM-NEXT:     Offset: 0x50
 // LLVM-NEXT:     Size: 0x2C
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: XYZ
-// LLVM-NEXT:       Data size: 0x1C
-// LLVM-NEXT:       Type: Unknown (0x00000003)
-// LLVM-NEXT:       Description data (
-// LLVM-NEXT:         0000: 4C6F7265 6D206970 73756D20 646F6C6F  |Lorem ipsum dolo|
-// LLVM-NEXT:         0010: 72207369 7420616D 65740000           |r sit amet..|
-// LLVM-NEXT:       )
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: XYZ
+// LLVM-NEXT:			Data size: 0x1C
+// LLVM-NEXT:			Type: Unknown (0x00000003)
+// LLVM-NEXT:			Description data (
+// LLVM-NEXT:				0000: 4C6F7265 6D206970 73756D20 646F6C6F  |Lorem ipsum dolo|
+// LLVM-NEXT:				0010: 72207369 7420616D 65740000           |r sit amet..|
+// LLVM-NEXT:			)
+// LLVM-NEXT:		}
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT:   NoteSection {
 // LLVM-NEXT:     Name: .note.8
 // LLVM-NEXT:     Offset: 0x80
 // LLVM-NEXT:     Size: 0x40
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: WXYZ
-// LLVM-NEXT:       Data size: 0x8
-// LLVM-NEXT:       Type: Unknown (0x00000006)
-// LLVM-NEXT:       Description data (
-// LLVM-NEXT:         0000: 4C6F7265 6D000000                    |Lorem...|
-// LLVM-NEXT:       )
-// LLVM-NEXT:     }
-// LLVM-NEXT:     Note {
-// LLVM-NEXT:       Owner: VWXYZ
-// LLVM-NEXT:       Data size: 0x8
-// LLVM-NEXT:       Type: Unknown (0x00000006)
-// LLVM-NEXT:       Description data (
-// LLVM-NEXT:         0000: 78787800 00000000                    |xxx.....|
-// LLVM-NEXT:       )
-// LLVM-NEXT:     }
+// LLVM-NEXT:	  Notes [
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: WXYZ
+// LLVM-NEXT:			Data size: 0x8
+// LLVM-NEXT:			Type: Unknown (0x00000006)
+// LLVM-NEXT:			Description data (
+// LLVM-NEXT:				0000: 4C6F7265 6D000000                    |Lorem...|
+// LLVM-NEXT:			)
+// LLVM-NEXT:		}
+// LLVM-NEXT:		{
+// LLVM-NEXT:			Owner: VWXYZ
+// LLVM-NEXT:			Data size: 0x8
+// LLVM-NEXT:			Type: Unknown (0x00000006)
+// LLVM-NEXT:			Description data (
+// LLVM-NEXT:				0000: 78787800 00000000                    |xxx.....|
+// LLVM-NEXT:			)
+// LLVM-NEXT:		}
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT: ]
 
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index a986ba88fdcfd..97d05c2abb0ff 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -7915,22 +7915,27 @@ static void printCoreNoteLLVMStyle(const CoreNote &Note, ScopedPrinter &W) {
 template <class ELFT> void LLVMELFDumper<ELFT>::printNotes() {
   ListScope L(W, "Notes");
 
-  std::unique_ptr<DictScope> NoteScope;
+  std::unique_ptr<DictScope> NoteSectionScope;
+  std::unique_ptr<ListScope> NotesScope;
   size_t Align = 0;
   auto StartNotes = [&](std::optional<StringRef> SecName,
                         const typename ELFT::Off Offset,
                         const typename ELFT::Addr Size, size_t Al) {
     Align = std::max<size_t>(Al, 4);
-    NoteScope = std::make_unique<DictScope>(W, "NoteSection");
+    NoteSectionScope = std::make_unique<DictScope>(W, "NoteSection");
     W.printString("Name", SecName ? *SecName : "<?>");
     W.printHex("Offset", Offset);
     W.printHex("Size", Size);
+    NotesScope = std::make_unique<ListScope>(W, "Notes");
   };
 
-  auto EndNotes = [&] { NoteScope.reset(); };
+  auto EndNotes = [&] {
+    NotesScope.reset();
+    NoteSectionScope.reset();
+  };
 
   auto ProcessNote = [&](const Elf_Note &Note, bool IsCore) -> Error {
-    DictScope D2(W, "Note");
+    DictScope D2(W);
     StringRef Name = Note.getName();
     ArrayRef<uint8_t> Descriptor = Note.getDesc(Align);
     Elf_Word Type = Note.getType();

>From 7d27fb96220417485a7e79fb36ba29f15f703c60 Mon Sep 17 00:00:00 2001
From: Fred Grim <fgrim at apple.com>
Date: Thu, 27 Jun 2024 05:45:24 -0700
Subject: [PATCH 2/2] missed a few failing tests

---
 llvm/test/tools/llvm-objcopy/ELF/add-note.test                | 4 +++-
 .../tools/llvm-readobj/ELF/AArch64/aarch64-feature-pauth.s    | 4 +++-
 .../llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s      | 4 +++-
 llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test          | 4 +++-
 .../tools/llvm-readobj/ELF/AArch64/note-android-unknown.test  | 4 +++-
 llvm/test/tools/llvm-readobj/ELF/note-core.test               | 2 +-
 6 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/llvm/test/tools/llvm-objcopy/ELF/add-note.test b/llvm/test/tools/llvm-objcopy/ELF/add-note.test
index b68103b665db3..af401169e3cc2 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/add-note.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/add-note.test
@@ -27,11 +27,13 @@ FileHeader:
 # CHECK-NEXT:     Name: .note.gnu.build-id
 # CHECK-NEXT:     Offset:
 # CHECK-NEXT:     Size:
-# CHECK-NEXT:     Note {
+# CHECK-NEXT:     Notes [
+# CHECK-NEXT:     {
 # CHECK-NEXT:       Owner: GNU
 # CHECK-NEXT:       Data size: 0x10
 # CHECK-NEXT:       Type: NT_GNU_BUILD_ID
 # CHECK-NEXT:       Build ID: 000102030405060708090a0b0c0d0e0f
 # CHECK-NEXT:     }
+# CHECK-NEXT:   ]
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-feature-pauth.s b/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-feature-pauth.s
index 512531748cd25..e178ded9c63c1 100644
--- a/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-feature-pauth.s
+++ b/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-feature-pauth.s
@@ -32,7 +32,8 @@ end:
 # OBJ-NEXT:     Name: .note.gnu.property
 # OBJ-NEXT:     Offset: 0x40
 # OBJ-NEXT:     Size: 0x28
-# OBJ-NEXT:     Note {
+# OBJ-NEXT:     Notes [
+# OBJ-NEXT:     {
 # OBJ-NEXT:       Owner: GNU
 # OBJ-NEXT:       Data size: 0x18
 # OBJ-NEXT:       Type: NT_GNU_PROPERTY_TYPE_0 (property note)
@@ -40,6 +41,7 @@ end:
 # OBJ-NEXT:         AArch64 PAuth ABI core info: platform [[PLATFORM]], version [[VERSION]]
 # OBJ-NEXT:       ]
 # OBJ-NEXT:     }
+# OBJ-NEXT:		]
 # OBJ-NEXT:   }
 # OBJ-NEXT: ]
 
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
index b517f0b381554..177a7f283e238 100644
--- 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
@@ -14,7 +14,8 @@
 // LLVM-NEXT:     Name: .note.gnu.property
 // LLVM-NEXT:     Offset: 0x40
 // LLVM-NEXT:     Size: 0x20
-// LLVM-NEXT:     Note {
+// LLVM-NEXT:     Notes [
+// LLVM-NEXT:     {
 // LLVM-NEXT:       Owner: GNU
 // LLVM-NEXT:       Data size: 0x10
 // LLVM-NEXT:       Type: NT_GNU_PROPERTY_TYPE_0 (property note)
@@ -22,6 +23,7 @@
 // LLVM-NEXT:         aarch64 feature: BTI, PAC, GCS
 // LLVM-NEXT:       ]
 // LLVM-NEXT:     }
+// LLVM-NEXT:	 ]
 // LLVM-NEXT:   }
 // LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test b/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
index 4bc9308feda0b..8f88f402be99d 100644
--- a/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
+++ b/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
@@ -96,7 +96,8 @@
 # LLVM-NEXT:     Offset: 0x40
 # LLVM-OK-NEXT:  Size: 0x18
 # LLVM-BAD-NEXT: Size: 0x14
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: Android
 # LLVM-OK-NEXT:    Data size: 0x4
 # LLVM-BAD-NEXT:   Data size: 0x0
@@ -114,6 +115,7 @@
 # NOSTACK-NEXT:    Stack: Disabled
 
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/AArch64/note-android-unknown.test b/llvm/test/tools/llvm-readobj/ELF/AArch64/note-android-unknown.test
index 3e48086ba6a98..943b31073cbec 100644
--- a/llvm/test/tools/llvm-readobj/ELF/AArch64/note-android-unknown.test
+++ b/llvm/test/tools/llvm-readobj/ELF/AArch64/note-android-unknown.test
@@ -12,7 +12,8 @@
 # LLVM-NEXT:     Name: .note.android.unknown
 # LLVM-NEXT:     Offset: 0x40
 # LLVM-NEXT:     Size: 0x1C
-# LLVM-NEXT:     Note {
+# LLVM-NEXT:     Notes [
+# LLVM-NEXT:     {
 # LLVM-NEXT:       Owner: Android
 # LLVM-NEXT:       Data size: 0x5
 # LLVM-NEXT:       Type: Unknown (0x00001337)
@@ -20,6 +21,7 @@
 # LLVM-NEXT:         0000: 01234567 89
 # LLVM-NEXT:       )
 # LLVM-NEXT:     }
+# LLVM-NEXT:    ]
 # LLVM-NEXT:   }
 # LLVM-NEXT: ]
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/note-core.test b/llvm/test/tools/llvm-readobj/ELF/note-core.test
index 484638e05d512..5d073333cd762 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-core.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-core.test
@@ -285,7 +285,7 @@
 # CHECK-GNU-EMPTY:
 
 # CHECK-LLVM:       Size: 0x14
-# CHECK-LLVM-NEXT:  Notes: [
+# CHECK-LLVM-NEXT:  Notes [
 # CHECK-LLVM-NEXT:  {
 # CHECK-LLVM-NEXT:   Owner: CORE
 # CHECK-LLVM-NEXT:   Data size: 0x0



More information about the llvm-commits mailing list