Files
clang-p2996/llvm/test/tools/llvm-readobj/ELF/note-multiple-sections.test
Fred Grim ab930ee7ca [llvm-readobj][ELF] Alter JSON/LLVM output on note sections to allow for multiple notes per section in JSON (#96813)
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:

```
NoteSections [
  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........@@....|
	  ...
```
2024-07-03 09:19:18 -07:00

40 lines
1.1 KiB
Plaintext

## Test that note values are interpreted correctly for 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