GNU readelf exits with an error for a number of invalid file cases.
Previously ELF Tool Chain readelf always exited with 0. Now we exit 1
upon detecting an error with one or more input files, but in any case
all of them are processed.
This should catch common failure cases. We still do not report an error
for some types of malformed ELF files, but this is consistent with GNU
readelf.
PR: 252727
Reviewed by: jkoshy, markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29377
Previously corrupt note namesz or descsz (perhaps caused by readelf's
current lack of endian support for notes) resulted in a crash. Check
that namesz and descsz do not extend beyond the end of the buffer before
trying to access name and desc data.
Reported by: jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
This will be used to tag binaries that require W+X mappings, in advance
of the ability to prevent W^X in mmap/mprotect.
There is still some discussion about the flag's name, but the ABI won't
change even if the name does (as kib pointed out in the review).
Reviewed by: csjp, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23909
From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE). Commited
upstream (in a slightly different form) as r3831.
Sponsored by: The FreeBSD Foundation
The caller of dump_object() is responsible for opening the file, let it
be responsible for closing too.
CID: 1411588
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Summary: A follow-on to r276634, which added the VMX note to userland cores,
and r334538 for VSX notes.
Copied from note_type_linux_core().
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D22404
The low fd limit used by poudriere exposed an odd failure mode in
cap_fileargs (used by readelf as of r350516). In particular, when
the limit was hit, both the main process and casper service would
block on their shared socket, waiting forever for the other to send a
message.
Reported by: zeising
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
These bits are used for Intel CET IBT/Shadow Stack.
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20516
This allows DWARF debugging output to use the common register
mneumonics, such as ra, sp, or t0.
DWARF registers 0-31 are mapped to the 32 general purpose registers,
which are then followed by the 32 floating point registers.
Reviewed by: markj
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20779
This prints out description text with the meaning of 'Flags' value in PowerPC64.
Example:
$ readelf -h ~/tmp/t1-Flag2
ELF Header:
Magic: 7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: FreeBSD
ABI Version: 0
Type: EXEC (Executable file)
Machine: PowerPC 64-bit
Version: 0x1
Entry point address: 0x10010000
Start of program headers: 64 (bytes into file)
Start of section headers: 209368 (bytes into file)
Flags: 0x2, OpenPOWER ELF V2 ABI
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 10
Size of section headers: 64 (bytes)
Number of section headers: 34
Section header string table index: 31
Submitted by: alfredo.junior_eldorado.org.br
Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D20782
- Add constants for OpenBSD wxneeded, bootdata and randomize to the
FreeBSD elf_common.h file. This is the file that gets used by the
elftoolchain library.
- Update readelf and elfdump utilities to decode these program headers
if they are encountered.
Note: FreeBSD has it's own version of elfdump(1), which will be updated
in a subsequent commit. I am adding it here anyway because this diff is
going to be submitted upstream.
Discussed with: emaste
Reviewed by: imp
MFC afer: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20548
M contrib/elftoolchain/elfdump/elfdump.c
M contrib/elftoolchain/readelf/readelf.c
M sys/sys/elf_common.h
Use an array instead of STAILQ, and sort at the end instead of while
adding new elements.
PR: 212539
Submitted by: Bora Özarslan <borako.ozarslan@gmail.com>
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
r345620 by kib@ fixed the rtld issue that caused a crash at startup
during resolution of libc's ifuncs with BIND_NOW.
PR: 233333
Sponsored by: The FreeBSD Foundation
Fewer lines of code and more maintainable.
Reviewed by: brooks, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19053
Output format is compatible with GNU readelf's handling of unknown note
types (modulo a GNU char signedness bug); future changes will add type-
specific decoding.
Reviewed by: kib
MFC after: 1 week
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Highlights:
- Make sure that only TLS sections are sorted into TLS segment.
- Fixed multiple errors in "Section to Segment mapping".
- Man page updates
- ar improvements
- elfcopy: avoid filter_reloc uninitialized variable for rela
- elfcopy: avoid stripping relocations from static binaries
- readelf: avoid printing directory in front of absolute path
- readelf: add NT_FREEBSD_FEATURE_CTL FreeBSD note type
- test improvements
NOTES:
Some of these changes originated in FreeBSD and simply reduce diffs
between contrib and vendor.
ELF Tool Chain ar is not (currently) used in FreeBSD, and there are
improvements in both FreeBSD and ELF Tool Chain ar that are not in
the other.
Sponsored by: The FreeBSD Foundation
is that both file name and current directory is recorded, however
file name sometimes already contains absolute path. In which case
prefixing it with directory name results in an invalid pathname.
Only append directory name if the file name does not start with '/'.
This seems to DTRT.
Approved by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18290
This ELF note will be used to allow binaries to opt out of, or in to,
upcoming vulnerability mitigation and other features.
Committing the definition and readelf change separately to allow
independent MFC.
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
NT_GNU_PROPERTY_TYPE_0 in a .note.gnu.property section "contains a
program property note which describes special handling requirements
for linker and run-time loader." (from the System V Application Binary
Interface - Linux Extensions")
Intel CET uses two processor-specific program properties in
NT_GNU_PROPERTY_TYPE_0: GNU_PROPERTY_X86_FEATURE_1_IBT to indicate that
all executable sections are compatible with Indirect Branch Tracking,
and GNU_PROPERTY_X86_FEATURE_1_SHSTK to indicate that sections are
compatible with shadow stack.
A later change should add decoding of the individual properties.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Previously these were shown only for MIPS objects.
Obtained from: ELF Tool Chain r3564
MFC after: 1 week
MFC with: r321045
Sponsored by: The FreeBSD Foundation