about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-05-16 06:17:14 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-05-18 13:04:13 -0700
commit2d5ec6692f5746ccb11db60976a6481ef8e9d74f (patch)
tree93ce3ec2b6d4fb72bcd3bac0432ea1405683c967 /elf
parent728894dba4a19578bd803906de184a8dd51ed13c (diff)
downloadglibc-2d5ec6692f5746ccb11db60976a6481ef8e9d74f.tar.gz
glibc-2d5ec6692f5746ccb11db60976a6481ef8e9d74f.tar.xz
glibc-2d5ec6692f5746ccb11db60976a6481ef8e9d74f.zip
Enable DT_RELR in glibc shared libraries and PIEs automatically
Enable DT_RELR in glibc shared libraries and position independent
executables (PIE) automatically if linker supports -z pack-relative-relocs.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile5
1 files changed, 4 insertions, 1 deletions
diff --git a/elf/Makefile b/elf/Makefile
index ce3345ed92..6f4ea78007 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1342,6 +1342,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
 # if the sanity check below fails.
 	$(LINK.o) -nostdlib -nostartfiles -shared -o $@.new		\
 		  $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now))	\
+		  $(dt-relr-ldflag) \
 		  $(filter-out $(map-file),$^) $(load-map-file)		\
 		  -Wl,-soname=$(rtld-installed-name)
 	$(call after-link,$@.new)
@@ -1666,6 +1667,7 @@ $(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
 
 $(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
 	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  $(dt-relr-ldflag) \
 		  -L$(subst :, -L,$(rpath-link)) \
 		  -Wl,-rpath-link=$(rpath-link) \
 		  $< -Wl,-F,$(objpfx)filtmod2.so
@@ -2469,7 +2471,7 @@ $(objpfx)tst-big-note: $(objpfx)tst-big-note-lib.so
 # artificial, large note in tst-big-note-lib.o and invalidate the
 # test.
 $(objpfx)tst-big-note-lib.so: $(objpfx)tst-big-note-lib.o
-	$(LINK.o) -shared -o $@ $(LDFLAGS.so) $<
+	$(LINK.o) -shared -o $@ $(LDFLAGS.so) $(dt-relr-ldflag) $<
 
 $(objpfx)tst-unwind-ctor: $(objpfx)tst-unwind-ctor-lib.so
 
@@ -2778,6 +2780,7 @@ $(objpfx)tst-ro-dynamic: $(objpfx)tst-ro-dynamic-mod.so
 $(objpfx)tst-ro-dynamic-mod.so: $(objpfx)tst-ro-dynamic-mod.os \
   tst-ro-dynamic-mod.map
 	$(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
+		$(dt-relr-ldflag) \
 		-Wl,--script=tst-ro-dynamic-mod.map \
 		$(objpfx)tst-ro-dynamic-mod.os