readelf: Support SHT_RELR/DT_RELR for -r

The -r output for SHT_RELR looks like:

Relocation section '.relr.dyn' at offset 0x530 contains 4 entries:
  7 offsets
00000000000028c0
00000000000028c8
0000000000003ad0
0000000000003ad8
0000000000003ae0
0000000000003ae8
0000000000003af0

For --use-dynamic, the header looks like

    'RELR' relocation section at offset 0x530 contains 32 bytes:

include/
    * elf/common.h (DT_ENCODING): Bump to 38.
    * elf/external.h (Elf32_External_Relr): New.
    (Elf64_External_Relr): New.
binutils/
    * readelf.c (enum relocation_type): New.
    (slurp_relr_relocs): New.
    (dump_relocations): Change is_rela to rel_type.
    Dump RELR.
    (dynamic_relocations): Add DT_RELR.
    (process_relocs): Check SHT_RELR and DT_RELR.
    (process_dynamic_section): Store into dynamic_info for
    DT_RELR/DT_RELRENT/DT_RELRSZ.
This commit is contained in:
Fangrui Song
2021-11-16 13:03:57 -08:00
parent 830070c66d
commit a7fd118627
6 changed files with 153 additions and 30 deletions

View File

@@ -211,6 +211,10 @@ typedef struct {
unsigned char r_addend[4]; /* Constant addend used to compute value */
} Elf32_External_Rela;
typedef struct {
unsigned char r_data[4]; /* RELR entry */
} Elf32_External_Relr;
typedef struct {
unsigned char r_offset[8]; /* Location at which to apply the action */
unsigned char r_info[8]; /* index and type of relocation */
@@ -222,6 +226,10 @@ typedef struct {
unsigned char r_addend[8]; /* Constant addend used to compute value */
} Elf64_External_Rela;
typedef struct {
unsigned char r_data[8]; /* RELR entry */
} Elf64_External_Relr;
/* dynamic section structure */
typedef struct {