[Toybox] One for Elliott.

enh enh at google.com
Wed May 13 09:10:08 PDT 2020


yeah, i actually left a comment in the source about this one.

basically, binutils readelf lies --- it takes two passes over the
array, counting non-null entries the first time and then only
admitting to the existence of the non-null entries. at the same time
(and it's hard to know which way round the causality goes here) some
versions of some of binutils' linkers would leave a bunch of null
entries at the end, as you see from this genuine example that _wasn't_
specifically picked for that purpose.

i resolved in favor of telling the exact truth (on the theory that
that's kind of why anyone's running readelf in the first place). but i
can see an argument for doing what the other guy does too, and can
send you the patch if you'd rather do that. at least we have the code
comment to explain the otherwise unnecessary first pass over the array
:-)

On Wed, May 13, 2020 at 4:23 AM Rob Landley <rob at landley.net> wrote:
>
> $ TEST_HOST=1 make test_readelf
> ...
> FAIL: readelf -d
> echo -ne '' | readelf -dW
> /home/landley/toybox/toybox/subdued/tests/files/elf/ndk-elf-note-full
> --- expected    2020-05-13 03:54:51.324153627 -0500
> +++ actual      2020-05-13 03:54:51.324153627 -0500
> @@ -1,5 +1,5 @@
>
> -Dynamic section at offset 0xd98 contains 33 entries:
> +Dynamic section at offset 0xd98 contains 29 entries:
>    Tag                Type                 Name/Value
>   0x0000000000000001 (NEEDED)             Shared library: [libc.so]
>   0x0000000000000001 (NEEDED)             Shared library: [libm.so]
> @@ -30,7 +30,3 @@
>   0x000000006ffffff0 (VERSYM)             0x528
>   0x000000006ffffff9 (RELACOUNT)          4
>   0x0000000000000000 (NULL)               0x0
> - 0x0000000000000000 (NULL)               0x0
> - 0x0000000000000000 (NULL)               0x0
> - 0x0000000000000000 (NULL)               0x0
> - 0x0000000000000000 (NULL)               0x0
>
> ... what?
>
> Rob



More information about the Toybox mailing list