On Thu, Aug 24, 2023 at 12:02:11AM +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 pluse symbol/offsets by default.
> 
>       * 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.
>       * 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.
> 
> Signed-off-by: Mark Wielaard <m...@klomp.org>
> ---
>  libebl/eblsectiontypename.c |   3 +-
>  libelf/elf32_updatenull.c   |   3 +
>  libelf/gelf.h               |   3 +
>  libelf/gelf_fsize.c         |   3 +-
>  libelf/gelf_xlate.c         |   3 +-
>  libelf/gelf_xlate.h         |   1 +
>  libelf/libelf.h             |   1 +
>  libelf/libelfP.h            |   2 +
>  src/elflint.c               |  51 +++++++++++++--
>  src/readelf.c               | 125 ++++++++++++++++++++++++++++++++++--
>  10 files changed, 184 insertions(+), 11 deletions(-)
> 
> diff --git a/libebl/eblsectiontypename.c b/libebl/eblsectiontypename.c
> index 2008b95a..ade25d4a 100644
> --- a/libebl/eblsectiontypename.c
> +++ b/libebl/eblsectiontypename.c
> @@ -61,7 +61,8 @@ ebl_section_type_name (Ebl *ebl, int section, char *buf, 
> size_t len)
>         KNOWNSTYPE (FINI_ARRAY),
>         KNOWNSTYPE (PREINIT_ARRAY),
>         KNOWNSTYPE (GROUP),
> -       KNOWNSTYPE (SYMTAB_SHNDX)
> +       KNOWNSTYPE (SYMTAB_SHNDX),
> +       KNOWNSTYPE (RELR)
>       };
>  
>        /* Handle standard names.  */
> diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
> index 6c06e5e4..c5d26b00 100644
> --- a/libelf/elf32_updatenull.c
> +++ b/libelf/elf32_updatenull.c
> @@ -256,6 +256,9 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int 
> *change_bop, size_t shnum)
>               case SHT_SUNW_syminfo:
>                 sh_entsize = elf_typesize (LIBELFBITS, ELF_T_SYMINFO, 1);
>                 break;
> +             case SHT_RELR:
> +               sh_entsize = elf_typesize (LIBELFBITS, ELF_T_RELR, 1);
> +               break;
>               default:
>                 break;
>               }
> diff --git a/libelf/gelf.h b/libelf/gelf.h
> index 7a3c87aa..f032d7e1 100644
> --- a/libelf/gelf.h
> +++ b/libelf/gelf.h
> @@ -82,6 +82,9 @@ typedef Elf64_Rel GElf_Rel;
>  /* Relocation table entry with addend (in section of type SHT_RELA).  */
>  typedef Elf64_Rela GElf_Rela;
>  
> +/* Relative relocation entry (in section of type SHT_RELR).  */
> +typedef Elf64_Relr Gelf_Relr;

Should this be GElf_Relr (with an uppercase E in GElf like the other
typedefs)?

Reply via email to