[PATCHv2] libelf, readelf, elflint: Add RELR support

Mark Wielaard mark@klomp.org
Tue Aug 29 10:55:52 GMT 2023


Hi,

On Fri, 2023-08-25 at 01:33 +0200, Mark Wielaard wrote:
> 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>
> ---
> 
> v2
> - Fix GElf_Relr typedef name
> - Add RELR typedefs/defines if missing from system elf.h
> - Add a system-elf-gelf-test

I pushed this variant. The same, minus the new testcase has also been
backported to Fedora rawhide.

Cheers,

Mark


More information about the Elfutils-devel mailing list