[llvm-readobj] Add support for decoding FreeBSD ELF notes
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Tue, 9 Feb 2021 16:46:29 +0000 (16:46 +0000)
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Tue, 9 Feb 2021 16:59:22 +0000 (16:59 +0000)
commit7dc31360339268b25d49680d23268731b33f51aa
treeb7d31b3b41b59ac5e9b12def460c933d6911d395
parent135df21248985579710e0cd3013d369de52dd354
[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
llvm/include/llvm/BinaryFormat/ELF.h
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/test/tools/llvm-readobj/ELF/note-freebsd-core.test [new file with mode: 0644]
llvm/test/tools/llvm-readobj/ELF/note-freebsd.s [deleted file]
llvm/test/tools/llvm-readobj/ELF/note-freebsd.test [new file with mode: 0644]
llvm/tools/llvm-readobj/ELFDumper.cpp