]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Compile test modules with -fsemantic-interposition
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 17 Dec 2024 23:24:38 +0000 (07:24 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 22 Dec 2024 05:15:43 +0000 (13:15 +0800)
Compiler may default to -fno-semantic-interposition. But some elf test
modules must be compiled with -fsemantic-interposition to function properly.
Add a TEST_CC check for -fsemantic-interposition and use it on elf test
modules.  This fixed

FAIL: elf/tst-dlclose-lazy
FAIL: elf/tst-pie1
FAIL: elf/tst-plt-rewrite1
FAIL: elf/unload4

when Clang 19 is used to test glibc.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
configure
configure.ac
elf/Makefile
sysdeps/x86_64/Makefile

index 58f05957f4c254c7000dee60f23b4b1dc8ed294b..60fe529392d8e34d573a9350bb2f30ad525f7fb1 100755 (executable)
--- a/configure
+++ b/configure
@@ -7720,6 +7720,40 @@ config-cflags-signaling-nans = $libc_cv_cc_signaling_nans"
 
 
 
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking -fsemantic-interposition in testing" >&5
+printf %s "checking -fsemantic-interposition in testing... " >&6; }
+if test ${libc_cv_test_cc_cflags_fsemantic_interposition+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if { ac_try='${CC-cc} -c -Werror -fsemantic-interposition -xc /dev/null -S -o /dev/null'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then :
+  libc_cv_test_cc_cflags_fsemantic_interposition=yes
+else case e in #(
+  e) libc_cv_test_cc_cflags_fsemantic_interposition=no
+ ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_cflags_fsemantic_interposition" >&5
+printf "%s\n" "$libc_cv_test_cc_cflags_fsemantic_interposition" >&6; }
+
+CC="$saved_CC"
+
+
+config_vars="$config_vars
+have-test-cc-cflags-fsemantic-interposition = $libc_cv_test_cc_cflags_fsemantic_interposition"
+
+
+
 saved_CC="$CC"
 CC="$TEST_CC"
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -ffloat-store in testing" >&5
index 8f75b319a3b47a7b0b7db5717e6e3b9166cf4453..bcf37310dfc29c7c8ccf2baf96fe67797d63a6f7 100644 (file)
@@ -1504,6 +1504,16 @@ LIBC_CONFIG_VAR([config-cflags-signaling-nans],
                [$libc_cv_cc_signaling_nans])
 AC_SUBST(libc_cv_test_cc_signaling_nans)
 
+dnl Check if TEST_CC supports -fsemantic-interposition.
+LIBC_TRY_TEST_CC_OPTION([-fsemantic-interposition],
+  [-c -Werror -fsemantic-interposition],
+  libc_cv_test_cc_cflags_fsemantic_interposition,
+  [libc_cv_test_cc_cflags_fsemantic_interposition=yes],
+  [libc_cv_test_cc_cflags_fsemantic_interposition=no]
+)
+LIBC_CONFIG_VAR(have-test-cc-cflags-fsemantic-interposition,
+               $libc_cv_test_cc_cflags_fsemantic_interposition)
+
 dnl Determine if TEST_CC supports -ffloat-store.
 LIBC_TRY_TEST_CC_OPTION([for -ffloat-store],
   [-Werror -ffloat-store],
index b62836d79c8c9e5421cf590ca7ad694386e3fc77..3c17688f19d55c3ae8f72225e2fec59d7012d2f1 100644 (file)
@@ -3293,3 +3293,23 @@ tst-tls22-mod1.so-no-z-defs = yes
 tst-tls22-mod1-gnu2.so-no-z-defs = yes
 tst-tls22-mod2.so-no-z-defs = yes
 tst-tls22-mod2-gnu2.so-no-z-defs = yes
+
+ifeq ($(have-test-cc-cflags-fsemantic-interposition),yes)
+# Compiler may default to -fno-semantic-interposition.  These modules
+# must be compiled with -fsemantic-interposition.
+modules-semantic-interposition = \
+  tst-dlclose-lazy-mod1 \
+  tst-dlclose-lazy-mod2 \
+  tst-piemod1 \
+  unload4mod1 \
+  unload4mod2 \
+  unload4mod3 \
+  unload4mod4 \
+# modules-semantic-interposition
+
+define enable-semantic-interposition
+CFLAGS-$(1).c += -fsemantic-interposition
+endef
+$(foreach m,$(modules-semantic-interposition),\
+  $(eval $(call enable-semantic-interposition,$(m))))
+endif
index 9e19cf7e8722d61326532b80427322eb520ca9aa..9d31685e028704a377d95f11e7c01927fd45d0de 100644 (file)
@@ -196,6 +196,9 @@ modules-names += \
 
 tst-plt-rewrite1-no-pie = yes
 LDFLAGS-tst-plt-rewrite1 = -Wl,-z,now
+ifeq ($(have-test-cc-cflags-fsemantic-interposition),yes)
+CFLAGS-tst-plt-rewritemod1.c += -fsemantic-interposition
+endif
 LDFLAGS-tst-plt-rewritemod1.so = -Wl,-z,now
 tst-plt-rewrite1-ENV = GLIBC_TUNABLES=glibc.cpu.plt_rewrite=1 LD_DEBUG=files:bindings
 $(objpfx)tst-plt-rewrite1: $(objpfx)tst-plt-rewritemod1.so