diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-12-18 07:24:38 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-12-22 13:15:43 +0800 |
commit | 03feea74dc75397f7eff10a92a322d235a6c1751 (patch) | |
tree | be382100801776188c66b19ddaa4b43b1e7d93c7 | |
parent | d085db5b57c71c3ee2fbfc38a4f7e2158abeb1d4 (diff) | |
download | glibc-03feea74dc75397f7eff10a92a322d235a6c1751.zip glibc-03feea74dc75397f7eff10a92a322d235a6c1751.tar.gz glibc-03feea74dc75397f7eff10a92a322d235a6c1751.tar.bz2 |
elf: Compile test modules with -fsemantic-interposition
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>
-rwxr-xr-x | configure | 34 | ||||
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | elf/Makefile | 20 | ||||
-rw-r--r-- | sysdeps/x86_64/Makefile | 3 |
4 files changed, 67 insertions, 0 deletions
@@ -7722,6 +7722,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 printf %s "checking for -ffloat-store in testing... " >&6; } if test ${libc_cv_test_cc_float_store+y} diff --git a/configure.ac b/configure.ac index 8f75b31..bcf3731 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/elf/Makefile b/elf/Makefile index b62836d..3c17688 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -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 diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index 9e19cf7..9d31685 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -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 |