From 395f920c0a29dd565a66b268ea00fc444ae64086 Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Tue, 6 Feb 2024 09:13:41 +0300 Subject: ld.so: Add support of DT_RELR relocation format. Nowadays modern libcs like Glibc and musl currently support processing of RELATIVE relocations compressed with DT_RELR format. However I have noticed that uClibc-ng doesn't support this feature and if the source will be linked with `-Wl,-z,pack-relative-relos` (bfd) or `-Wl,--pack-dyn-relocs=relr` (lld) then ld.so cannot properly load the produced DSO. This patch is intended to fix this issue and adds applying of DT_RELR relative relocation. Signed-off-by: Dmitry Chestnykh --- include/elf.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/elf.h b/include/elf.h index b7edbade2..c2efa9978 100644 --- a/include/elf.h +++ b/include/elf.h @@ -60,6 +60,9 @@ typedef uint16_t Elf64_Section; typedef Elf32_Half Elf32_Versym; typedef Elf64_Half Elf64_Versym; +/* Type for relative relocations in DT_RELR format */ +typedef Elf32_Word Elf32_Relr; +typedef Elf64_Xword Elf64_Relr; /* The ELF file header. This appears at the start of every ELF file. */ @@ -818,7 +821,10 @@ typedef struct #define DT_ENCODING 32 /* Start of encoded range */ #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used */ +#define DT_RELRSZ 35 /* Size in bytes, of DT_RELR table */ +#define DT_RELR 36 /* Address of Relr relocs */ +#define DT_RELRENT 37 /* Size in bytes of one DT_RELR entry */ +#define DT_NUM 38 /* Number used */ #define DT_LOOS 0x6000000d /* Start of OS-specific */ #define DT_HIOS 0x6ffff000 /* End of OS-specific */ #define DT_LOPROC 0x70000000 /* Start of processor-specific */ -- cgit v1.2.3