diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-08-22 16:27:15 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-04-17 16:12:41 -0300 |
commit | 4a17a44be54cd9db56117641c3e21c994cf31e27 (patch) | |
tree | b8fbef128b94d395828510c67f75c7c1f2f5eee4 | |
parent | cd90ccecee008afcd040177bfd02bb466c0c9300 (diff) | |
download | glibc-4a17a44be54cd9db56117641c3e21c994cf31e27.zip glibc-4a17a44be54cd9db56117641c3e21c994cf31e27.tar.gz glibc-4a17a44be54cd9db56117641c3e21c994cf31e27.tar.bz2 |
i686: Do not build ifunc tests if compiler does not generate supported relocations
clang with --target i668 might not produce supported relocations
that ld.bfd can use for -static-pie without -fPIC, which are used
on some tests. Disable them for now.
-rw-r--r-- | aclocal.m4 | 6 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | elf/Makefile | 18 | ||||
-rw-r--r-- | sysdeps/i386/configure | 31 | ||||
-rw-r--r-- | sysdeps/i386/configure.ac | 15 |
6 files changed, 71 insertions, 6 deletions
@@ -148,7 +148,7 @@ AC_SUBST(NM) ]) dnl Run a static link test with -nostdlib -nostartfiles. -dnl LIBC_TRY_LINK_STATIC([code], [action-if-true], [action-if-false]) +dnl LIBC_TRY_LINK_STATIC([code], [opts], [action-if-true], [action-if-false]) AC_DEFUN([LIBC_TRY_LINK_STATIC], [cat > conftest.c <<EOF int _start (void) { return 0; } @@ -156,9 +156,9 @@ int __start (void) { return 0; } $1 EOF AS_IF([AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -o conftest - conftest.c -static -nostartfiles -nostdlib + conftest.c $2 -static -nostartfiles -nostdlib 1>&AS_MESSAGE_LOG_FD])], - [$2], [$3]) + [$3], [$4]) rm -f conftest*]) dnl Test a compiler option or options with an empty input file. @@ -8002,6 +8002,7 @@ libc_cv_localstatedir=$localstatedir libc_cv_gcc_unwind_find_fde=no libc_cv_idn=no pthread_in_libc=yes +libc_cv_ifunc_static_pie=yes # Iterate over all the sysdep directories we will use, running their # configure fragments. @@ -8017,6 +8018,9 @@ printf "%s\n" "running configure fragment for $dir" >&6; } fi done +config_vars="$config_vars +ifunc-static-pie = $libc_cv_ifunc_static_pie" + if test x"$build_mathvec" = xnotset; then build_mathvec=no fi diff --git a/configure.ac b/configure.ac index 826d55d..2b2e2f4 100644 --- a/configure.ac +++ b/configure.ac @@ -1761,6 +1761,7 @@ libc_cv_localstatedir=$localstatedir libc_cv_gcc_unwind_find_fde=no libc_cv_idn=no pthread_in_libc=yes +libc_cv_ifunc_static_pie=yes # Iterate over all the sysdep directories we will use, running their # configure fragments. @@ -1775,6 +1776,8 @@ for dir in $sysnames; do fi done +LIBC_CONFIG_VAR([ifunc-static-pie], [$libc_cv_ifunc_static_pie]) + if test x"$build_mathvec" = xnotset; then build_mathvec=no fi diff --git a/elf/Makefile b/elf/Makefile index 0a901ae..9c91e8b 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1061,16 +1061,20 @@ tests += $(tests-static) ifeq (yes,$(have-ifunc)) tests-ifuncstatic := \ ifuncmain1picstatic \ - ifuncmain1static \ ifuncmain2picstatic \ ifuncmain2static \ ifuncmain4picstatic \ - ifuncmain4static \ ifuncmain5picstatic \ ifuncmain5static \ + # tests-ifuncstatic +ifeq (yes,$(ifunc-static-pie)) +tests-ifuncstatic += \ + ifuncmain1static \ + ifuncmain4static \ ifuncmain7picstatic \ ifuncmain7static \ # tests-ifuncstatic +endif ifeq (yes,$(have-gcc-ifunc)) tests-ifuncstatic += ifuncmain9static ifuncmain9picstatic endif @@ -1090,11 +1094,15 @@ tests-internal += \ ifuncmain2 \ ifuncmain2pic \ ifuncmain3 \ - ifuncmain4 \ ifuncmain5staticpic \ + # tests-internal +ifeq (yes,$(ifunc-static-pie)) +tests-internal += \ + ifuncmain4 \ ifuncmain7 \ ifuncmain7pic \ # tests-internal +endif ifeq (no,$(with-lld)) tests-internal += \ ifuncmain1 \ @@ -1123,9 +1131,13 @@ ifunc-pie-tests = \ ifuncmain1pie \ ifuncmain1staticpie \ ifuncmain1vispie \ + # ifunc-pie-tests +ifeq (yes,$(ifunc-static-pie)) +ifunc-pie-tests += \ ifuncmain6pie \ ifuncmain7pie \ # ifunc-pie-tests +endif ifeq (yes,$(have-gcc-ifunc)) ifunc-pie-tests += ifuncmain9pie endif diff --git a/sysdeps/i386/configure b/sysdeps/i386/configure index 84656ce..d10a9b6 100644 --- a/sysdeps/i386/configure +++ b/sysdeps/i386/configure @@ -89,6 +89,37 @@ printf "%s\n" "$libc_cv_ld_static_pie" >&6; } fi fi +if test "$libc_cv_static_pie" == "yes"; then + cat > conftest.c <<EOF +int _start (void) { return 0; } +int __start (void) { return 0; } +int foo (void) __attribute__ ((ifunc ("foo_ifunc"))); +void * +foo_ifunc (void) +{ + return 0; +} +int main (void) +{ + return foo (); +} +EOF +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -o conftest + conftest.c -fPIE -static-pie -static -nostartfiles -nostdlib + 1>&5' + { { 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_ifunc_static_pie=yes +else $as_nop + libc_cv_ifunc_static_pie=no +fi +rm -f conftest* +fi + if test x"$multi_arch" != xno; then printf "%s\n" "#define NO_HIDDEN_EXTERN_FUNC_IN_PIE 1" >>confdefs.h diff --git a/sysdeps/i386/configure.ac b/sysdeps/i386/configure.ac index 7f68e62..d61ab42 100644 --- a/sysdeps/i386/configure.ac +++ b/sysdeps/i386/configure.ac @@ -58,6 +58,21 @@ rm -f conftest*]) fi fi +if test "$libc_cv_static_pie" == "yes"; then + LIBC_TRY_LINK_STATIC([dnl +int foo (void) __attribute__ ((ifunc ("foo_ifunc"))); +void * +foo_ifunc (void) +{ + return 0; +} +int main (void) +{ + return foo (); +}], + [-fPIE -static-pie], libc_cv_ifunc_static_pie=yes, libc_cv_ifunc_static_pie=no) +fi + dnl When multi-arch is enabled, all external functions must be called dnl via PIC PLT in PIE, which requires setting up EBX register. if test x"$multi_arch" != xno; then |