Commit Graph

5 Commits

Author SHA1 Message Date
Christopher Ferris
b6d1d9068c readelf: Fix the section flags handling.
The array of section flags was missing the G flag, so any flags
after it were displayed incorrectly. And, of course, the G flag
was not displayed at all.

Added a new elf file with a section that include the T and C flags
and updated readelf.test to run this test. This test fails on the
old code and passes with the fix.
2023-11-30 13:08:04 -06:00
Rob Landley
c9e684a5a3 Replace more SKIP_HOST with toyonly.
SKIP_HOST won't run a test when TEST_HOST set, but toyonly runs its arguments
whenever testing toybox (including when the host version is toybox).
2020-05-29 00:34:24 -05:00
Rob Landley
f5ca2bcf2b toyonly a test binutils lies about, and add a TODO comment. 2020-05-13 16:00:07 -05:00
Elliott Hughes
1a79bd5628 readelf: various fixes.
Add -e, and stop documenting no-op -W.

Fix sign issues, and add a few extra sanity checks.

Redo the BE/LE 16/32/64 reading.

Remove the NOSPACE=1 from the -l test, and fix the -l code to match the
binutils output. Most usefully, this fixes the weird way the NULL
section's empty name would cause misalignment in the section to segment
mapping output.

Add a test for -s (symbol table).
2020-03-01 01:46:05 -06:00
Elliott Hughes
a3da7efae5 Implement readelf(1).
Basic readelf(1) implementation, with output close enough to the binutils
version to be usable with scripts that expect the binutils version. This
started as an implementation of nm(1) until I realized that I almost always
want readelf instead, and that you actually have to do much of the work
needed for readelf just to implement nm. Arguably nm (being part of POSIX)
belongs in toybox while readelf doesn't. An argument could also be made that
neither really belongs in toybox, belonging in a separate set of development
tools (such as binutils or the LLVM binutils).

Doesn't support most of the architecture-specific stuff, most notably
relocations, but is aware of things like ARM exidx sections and the common
register state notes in core dumps for the "big four" architectures: arm,
arm64, x86, and x86-64.

Doesn't support symbol versions (but probably should).

Doesn't support section groups or the -t "section details" (which is a long
form of -S "section headers" that I've never seen used in practice and which
isn't part of -a). Doesn't support dumping unwind info or the hash table
bucket histograms.

Reuses the table of ELF architectures from file(1).

Not fuzzed, but successfully parses all the ELF files in my Ubuntu 18.04
system's lib directories. Attempts to exit with an error when presented with
an invalid ELF file rather than struggle on as binutils seems to.
2020-01-08 17:51:57 -06:00