mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-29 08:11:08 +00:00
b53e73ea80
Instead of tying based on the linker name and version, check for the required support: * whether it does not generate dynamic TLS relocations in PIE (binutils PR ld/22263); * if it accepts --no-dynamic-linker (by using -static-pie); * and if it adds a DT_JMPREL pointing to .rela.iplt with static pie. The patch also trims the comments, for binutils one of the tests should already cover it. The kernel ones are not clear which version should have the backport, nor it is something that glibc can do much about it. Finally, the glibc is somewhat confusing, since it refers to commits not related to s390x. Checked with a build for s390x-linux-gnu. Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
58 lines
1.9 KiB
Plaintext
58 lines
1.9 KiB
Plaintext
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
|
|
# Local configure fragment for sysdeps/s390/s390-64.
|
|
|
|
# Minimal checking for static PIE support in ld.
|
|
# Compare to ld testcase/bugzilla:
|
|
# <binutils-source>/ld/testsuite/ld-elf/pr22263-1.rd
|
|
AC_CACHE_CHECK([for s390-specific static PIE requirements (runtime check)], \
|
|
[libc_cv_s390x_staticpie_req_runtime], [dnl
|
|
cat > conftest1.c <<EOF
|
|
__thread int * foo;
|
|
|
|
void
|
|
bar (void)
|
|
{
|
|
*foo = 1;
|
|
}
|
|
|
|
void bar2 (void);
|
|
void* bar2_ifunc (void) __asm__ ("bar2");
|
|
__asm__ (".type bar2, %gnu_indirect_function");
|
|
void* bar2_ifunc (void) { return 0; }
|
|
EOF
|
|
cat > conftest2.c <<EOF
|
|
extern __thread int *foo;
|
|
extern void bar (void);
|
|
extern void bar2 (void);
|
|
static int x;
|
|
|
|
int
|
|
main ()
|
|
{
|
|
foo = &x;
|
|
bar2 ();
|
|
return 0;
|
|
}
|
|
EOF
|
|
libc_cv_s390x_staticpie_req_runtime=no
|
|
# Check if the static linker does not generate dynamic TLS relocs in PIE
|
|
# (binutils PR ld/22263), if it accepts --no-dynamic-linker
|
|
# (by using -static-pie), and if it adds a DT_JMPREL pointing to .rela.iplt
|
|
# with static pie.
|
|
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest1.c -o conftest1.o]) \
|
|
&& AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest2.c -o conftest2.o]) \
|
|
&& AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostartfiles -nostdlib -fPIE -o conftest conftest1.o conftest2.o]) \
|
|
&& AC_TRY_COMMAND([! LC_ALL=C $READELF -Wr conftest | grep R_390_TLS_TPOFF]) \
|
|
&& AC_TRY_COMMAND([LC_ACLL=C $READELF -d conftest | grep JMPREL])
|
|
then
|
|
libc_cv_s390x_staticpie_req_runtime=yes
|
|
fi
|
|
rm -rf conftest.*])
|
|
|
|
if test $libc_cv_s390x_staticpie_req_runtime = yes; then
|
|
# Some kernels might fail with /proc/sys/kernel/randomize_va_space set to 0
|
|
# due not enough space for a brk call. However, there is no reliable way to
|
|
# test it.
|
|
AC_DEFINE(SUPPORT_STATIC_PIE)
|
|
fi
|