readelf: print addend for RELA relocations without symbol (#292)
authorAndreas Ziegler <andreas.ziegler@fau.de>
Sat, 7 Mar 2020 14:32:40 +0000 (15:32 +0100)
committerGitHub <noreply@github.com>
Sat, 7 Mar 2020 14:32:40 +0000 (06:32 -0800)
commit6fff9b53f24478610f4bc2e6a6e5b4d75f686f8a
tree6b888a0ec11d6a46dfdd3557aff24c81aee45906
parent25a0660ab27cce42275c0743e6b1a215c5a06e33
readelf: print addend for RELA relocations without symbol (#292)

* readelf: print addend for RELA relocations without symbol

When processing relocations from a SHT_RELA type section, GNU
readelf displays the value of the 'r_addend' field if no
symbol index is given (that is, 'r_info_sym' is 0).

By also implementing this we can better test the output for
64-bit binaries which commonly use SHT_RELA relocations.

The included test file is the same as tls.elf but compiled
for x86_64. Its code is the following:

  __thread int i;

  int main(){}

and it is compiled using the following command line:

$ gcc -m64 -o tls64.elf tls.c

* test: add source file for tls{,64}.elf

The comments at the top describe how to compile the source
file into tls.elf and tls64.elf.
scripts/readelf.py
test/testfiles_for_readelf/tls.c [new file with mode: 0644]
test/testfiles_for_readelf/tls64.elf [new file with mode: 0755]