llvm-project/llvm/test/tools/llvm-readobj/ELF/note-freebsd-core.test
Alex Richardson 7dc3136033 [llvm-readobj] Add support for decoding FreeBSD ELF notes
The current support only printed coredump notes, but most binaries also
contain notes. This change adds names for four FreeBSD-specific notes and
pretty-prints three of them:

NT_FREEBSD_ABI_TAG:
This note holds a 32-bit (decimal) integer containing the value of the
__FreeBSD_version macro, which is defined in crt1.o and will hold a value
such as 1300076 for a binary build on a FreeBSD 13 system.

NT_FREEBSD_ARCH_TAG:
A string containing the value of the build-time MACHINE_ARCH

NT_FREEBSD_FEATURE_CTL: A 32-bit flag that indicates to the kernel that
the binary wants certain bevahiour. Examples include setting
NT_FREEBSD_FCTL_ASLR_DISABLE which tells the kernel to disable ASLR.

After this change llvm-readobj also no longer decodes coredump-only
FreeBSD notes in non-coredump files. I've also converted the
note-freebsd.s test to use yaml2obj instead of llvm-mc.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D74393
2021-02-09 16:59:22 +00:00

146 lines
5.0 KiB
Plaintext

## Test that note values are interpreted correctly for FreeBSD 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: FreeBSD
Type: NT_FREEBSD_THRMISC
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_PROC
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_FILES
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_VMMAP
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_GROUPS
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_UMASK
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_RLIMIT
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_OSREL
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_PSSTRINGS
- Name: FreeBSD
Type: NT_FREEBSD_PROCSTAT_AUXV
- Name: FreeBSD
Type: 0x12345
- Name: .note.bar
Type: SHT_NOTE
Notes:
- Name: FreeBSD
Desc: 'aabbccddeeff'
Type: NT_PRPSINFO
ProgramHeaders:
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo
- Type: PT_NOTE
FirstSec: .note.bar
LastSec: .note.bar
# GNU: Displaying notes found at file offset 0x000000b0 with length 0x000000dc:
# 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: FreeBSD 0x00000000 NT_PROCSTAT_FILES (files data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_VMMAP (vmmap data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_GROUPS (groups data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_UMASK (umask data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_RLIMIT (rlimit data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_OSREL (osreldate data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_PSSTRINGS (ps_strings data)
# GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_AUXV (auxv data)
# GNU-NEXT: FreeBSD 0x00000000 Unknown note type: (0x00012345)
# GNU-EMPTY:
# GNU-NEXT: Displaying notes found at file offset 0x0000018c with length 0x0000001c:
# GNU-NEXT: Owner Data size Description
# GNU-NEXT: FreeBSD 0x00000006 NT_PRPSINFO (prpsinfo structure)
# GNU-NEXT: description data: aa bb cc dd ee ff
# GNU-EMPTY:
# LLVM: Notes [
# LLVM-NEXT: NoteSection {
# 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: }
# 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: }
# LLVM-NEXT: ]