Files
clang-p2996/llvm/test/tools/llvm-readobj/ELF/note-openbsd-core.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

72 lines
2.5 KiB
Plaintext

## Test that note values are interpreted correctly for OpenBSD core files.
# RUN: yaml2obj %s -o %t.o
# RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU --strict-whitespace
# RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM --strict-whitespace
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_CORE
Sections:
- Name: .note.foo
Type: SHT_NOTE
Notes:
- Name: OpenBSD
Type: NT_OPENBSD_PROCINFO
- Name: OpenBSD
Type: NT_OPENBSD_AUXV
- Name: OpenBSD
Type: NT_OPENBSD_WCOOKIE
- Name: OpenBSD@31337
Type: NT_OPENBSD_REGS
- Name: OpenBSD@31337
Type: NT_OPENBSD_FPREGS
ProgramHeaders:
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo
# GNU: Displaying notes found at file offset 0x00000078 with length 0x00000074:
# GNU-NEXT: Owner Data size Description
# GNU-NEXT: OpenBSD 0x00000000 NT_OPENBSD_PROCINFO (procinfo structure)
# GNU-NEXT: OpenBSD 0x00000000 NT_OPENBSD_AUXV (ELF auxiliary vector data)
# GNU-NEXT: OpenBSD 0x00000000 NT_OPENBSD_WCOOKIE (window cookie)
# GNU-NEXT: OpenBSD@31337 0x00000000 NT_OPENBSD_REGS (regular registers)
# GNU-NEXT: OpenBSD@31337 0x00000000 NT_OPENBSD_FPREGS (floating point registers)
# LLVM: NoteSections [
# LLVM-NEXT: NoteSection {
# LLVM-NEXT: Name: <?>
# LLVM-NEXT: Offset: 0x78
# LLVM-NEXT: Size: 0x74
# 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@31337
# LLVM-NEXT: Data size: 0x0
# LLVM-NEXT: Type: NT_OPENBSD_REGS (regular registers)
# LLVM-NEXT: }
# LLVM-NEXT: {
# LLVM-NEXT: Owner: OpenBSD@31337
# LLVM-NEXT: Data size: 0x0
# LLVM-NEXT: Type: NT_OPENBSD_FPREGS (floating point registers)
# LLVM-NEXT: }
# LLVM-NEXT: ]
# LLVM-NEXT: }
# LLVM-NEXT: ]