ldso: process RELR only for non-FDPIC archs
authorRich Felker <dalias@aerifal.cx>
Tue, 2 Aug 2022 21:29:01 +0000 (17:29 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 2 Aug 2022 21:29:01 +0000 (17:29 -0400)
the way RELR is applied is not a meaningful operation for FDPIC (there
is no single "base" address). it seems unlikely RELR would ever be
added for FDPIC, but if it ever is, the behavior and possibly data
format will need to be different, so guard against calling the
non-FDPIC code.

ldso/dynlink.c

index e92f03c..fd09ca6 100644 (file)
@@ -1375,7 +1375,8 @@ static void reloc_all(struct dso *p)
                        2+(dyn[DT_PLTREL]==DT_RELA));
                do_relocs(p, laddr(p, dyn[DT_REL]), dyn[DT_RELSZ], 2);
                do_relocs(p, laddr(p, dyn[DT_RELA]), dyn[DT_RELASZ], 3);
-               do_relr_relocs(p, laddr(p, dyn[DT_RELR]), dyn[DT_RELRSZ]);
+               if (!DL_FDPIC)
+                       do_relr_relocs(p, laddr(p, dyn[DT_RELR]), dyn[DT_RELRSZ]);
 
                if (head != &ldso && p->relro_start != p->relro_end) {
                        long ret = __syscall(SYS_mprotect, laddr(p, p->relro_start),