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 --- libc/misc/internals/reloc_static_pie.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libc/misc') diff --git a/libc/misc/internals/reloc_static_pie.c b/libc/misc/internals/reloc_static_pie.c index ab1923024..81af7d666 100644 --- a/libc/misc/internals/reloc_static_pie.c +++ b/libc/misc/internals/reloc_static_pie.c @@ -53,6 +53,9 @@ reloc_static_pie(ElfW(Addr) load_addr) PERFORM_BOOTSTRAP_GOT(tpnt); #endif +#if !defined(__FDPIC__) + DL_RELOCATE_RELR(tpnt); +#endif #if defined(ELF_MACHINE_PLTREL_OVERLAP) # define INDX_MAX 1 -- cgit v1.2.3