]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf, readelf, elflint: Add RELR support
authorMark Wielaard <mark@klomp.org>
Sun, 23 Jul 2023 21:14:31 +0000 (23:14 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 29 Aug 2023 10:39:45 +0000 (12:39 +0200)
commit39f2c500542f69c2f1a13fd0ae4eaa5778d2ed8d
tree7492eaabe326735e7f21dbebf5219f2e0e929a08
parent09e61a65953ed814d9e970f7f9ffb9c2d8cda477
libelf, readelf, elflint: Add RELR support

Handle RELR as defined here:
https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/YT2RrjpMAwAJ

Introduce new ELF_T_RELR Elf_Type and handle it for SHT_RELR.  Check
various properties in elflint.  Print RELR relocations in
readelf. Just the entries with -U.  Just the addresses with -N. And
addresses plus symbol/offsets by default.

Also add a test to check that gelf.h works with the system elf.h.

* libebl/eblsectiontypename.c (ebl_section_type_name): Add RELR
to knownstype.
* libelf/elf32_updatenull.c (updatenull_wrlock): Handle
sh_entsize for SHT_RELR.
* libelf/gelf.h (GElf_Relr): New typedef for Elf64_Relr.
* libelf/gelf_fsize.c (__libelf_type_sizes): Add ELF_T_RELR.
* libelf/gelf_xlate.c (__elf_xfctstom): Likewise.
* libelf/gelf_xlate.h: Add RELR as FUNDAMENTAL.
* libelf/libelf.h (Elf_Type): Add ELF_T_RELR. Add RELR
defines/typedefs if undefined in system elf.h.
* libelf/libelfP.h: Define ELF32_FSZ_RELR and ELF64_FSZ_RELR.
* src/elflint.c (check_reloc_shdr): Check she_entsize for
ELF_T_RELR.
(check_relr): New function.
(check_dynamic): Handle DT_RELR.
(special_sections): Add SHT_RELR.
(check_sections): Call check_relr.
* src/readelf.c (print_relocs): Also accept a Dwfl_Module.
(handle_relocs_relr): New function.
(print_dwarf_addr): Make static and declare early.
(process_elf_file): Pass dwflmod to print_relocs.
(handle_dynamic): Handle DT_RELRSZ and DTRELRENT.
* system-elf-gelf-test.c: New test.
* Makefile.am (TESTS): Add system-elf-gelf-test.
(check_PROGRAMS): Likewise.
(system_elf_gelf_test_CPPFLAGS): New variable.
(system_elf_gelf_test_LDADD): Likewise.

https://sourceware.org/bugzilla/show_bug.cgi?id=28495

Signed-off-by: Mark Wielaard <mark@klomp.org>
12 files changed:
libebl/eblsectiontypename.c
libelf/elf32_updatenull.c
libelf/gelf.h
libelf/gelf_fsize.c
libelf/gelf_xlate.c
libelf/gelf_xlate.h
libelf/libelf.h
libelf/libelfP.h
src/elflint.c
src/readelf.c
tests/Makefile.am
tests/system-elf-gelf-test.c [new file with mode: 0644]