about summary refs log tree commit diff
path: root/elf/Makefile
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2023-11-27 11:28:13 +0100
committerFlorian Weimer <fweimer@redhat.com>2023-11-27 11:28:13 +0100
commit78ca44da0160a0b442f0ca1f253e3360f044b2ec (patch)
tree248cff1b3dc9e22595ad4d9871598bf6bd389c74 /elf/Makefile
parenta74c2e1cbc8673dd7e97aae2f2705392e2ccc3f6 (diff)
downloadglibc-78ca44da0160a0b442f0ca1f253e3360f044b2ec.tar.gz
glibc-78ca44da0160a0b442f0ca1f253e3360f044b2ec.tar.xz
glibc-78ca44da0160a0b442f0ca1f253e3360f044b2ec.zip
elf: Relocate libc.so early during startup and dlmopen (bug 31083)
This makes it more likely that objects without dependencies can
use IFUNC resolvers in libc.so.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'elf/Makefile')
-rw-r--r--elf/Makefile21
1 files changed, 21 insertions, 0 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 3f7f89508e..afec7be084 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -433,6 +433,8 @@ tests += \
   tst-nodelete-dlclose \
   tst-nodelete-opened \
   tst-nodelete2 \
+  tst-nodeps1 \
+  tst-nodeps2 \
   tst-noload \
   tst-non-directory-path \
   tst-null-argv \
@@ -863,6 +865,8 @@ modules-names += \
   tst-nodelete-dlclose-plugin \
   tst-nodelete-opened-lib \
   tst-nodelete2mod \
+  tst-nodeps1-mod \
+  tst-nodeps2-mod \
   tst-non-directory-mod \
   tst-null-argv-lib \
   tst-p_alignmod-base \
@@ -1030,6 +1034,8 @@ modules-names-nobuild += \
   tst-audit24bmod1 \
   tst-audit24bmod2 \
   tst-big-note-lib \
+  tst-nodeps1-mod \
+  tst-nodeps2-mod \
   tst-ro-dynamic-mod \
   # modules-names-nobuild
 
@@ -3009,3 +3015,18 @@ tst-env-setuid-ARGS = -- $(host-test-program-cmd)
 
 # Reuse a module with a SONAME, to specific as the LD_PROFILE.
 $(objpfx)tst-env-setuid: $(objpfx)tst-sonamemove-runmod2.so
+
+# The object tst-nodeps1-mod.so has no explicit dependencies on libc.so.
+$(objpfx)tst-nodeps1-mod.so: $(objpfx)tst-nodeps1-mod.os
+	$(LINK.o) -nostartfiles -nostdlib -shared -o $@ $^
+tst-nodeps1.so-no-z-defs = yes
+# Link libc.so before the test module with the IFUNC resolver reference.
+LDFLAGS-tst-nodeps1 = $(common-objpfx)libc.so $(objpfx)tst-nodeps1-mod.so
+$(objpfx)tst-nodeps1: $(objpfx)tst-nodeps1-mod.so
+# Reuse the tst-nodeps1 module.  Link libc.so before the test module
+# with the IFUNC resolver reference.
+$(objpfx)tst-nodeps2-mod.so: $(common-objpfx)libc.so \
+  $(objpfx)tst-nodeps1-mod.so $(objpfx)tst-nodeps2-mod.os
+	$(LINK.o) -Wl,--no-as-needed -nostartfiles -nostdlib -shared -o $@ $^
+$(objpfx)tst-nodeps2.out: \
+  $(objpfx)tst-nodeps1-mod.so $(objpfx)tst-nodeps2-mod.so