diff --git a/configure b/configure index 58f05957f4..60fe529392 100755 --- 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 diff --git a/configure.ac b/configure.ac index 8f75b319a3..bcf37310df 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 b62836d79c..3c17688f19 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 9e19cf7e87..9d31685e02 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