mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
LoongArch: Simplify the autoconf check for static PIE
We are strictly requiring GAS >= 2.41 now, so we don't need to check assembler capability anymore. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
This commit is contained in:
parent
42c960a4f1
commit
e757412c3e
2 changed files with 16 additions and 50 deletions
36
sysdeps/loongarch/configure
vendored
36
sysdeps/loongarch/configure
vendored
|
@ -4,21 +4,19 @@
|
||||||
printf "%s\n" "#define HIDDEN_VAR_NEEDS_DYNAMIC_RELOC 1" >>confdefs.h
|
printf "%s\n" "#define HIDDEN_VAR_NEEDS_DYNAMIC_RELOC 1" >>confdefs.h
|
||||||
|
|
||||||
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the toolchain is sufficient to build static PIE on LoongArch" >&5
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if ${CC-cc} is sufficient to build static PIE on LoongArch" >&5
|
||||||
printf %s "checking if the toolchain is sufficient to build static PIE on LoongArch... " >&6; }
|
printf %s "checking if ${CC-cc} is sufficient to build static PIE on LoongArch... " >&6; }
|
||||||
if test ${libc_cv_static_pie_on_loongarch+y}
|
if test ${libc_cv_static_pie_on_loongarch+y}
|
||||||
then :
|
then :
|
||||||
printf %s "(cached) " >&6
|
printf %s "(cached) " >&6
|
||||||
else $as_nop
|
else $as_nop
|
||||||
|
|
||||||
cat > conftest1.S <<\EOF
|
cat > conftest.S <<\EOF
|
||||||
.global _start
|
.global _start
|
||||||
.type _start, @function
|
.type _start, @function
|
||||||
_start:
|
_start:
|
||||||
li.w $a7, 93
|
li.w $a7, 93
|
||||||
/* This ensures the assembler supports explicit reloc. */
|
li.w $a0, 0
|
||||||
pcalau12i $a0, %pc_hi20(x)
|
|
||||||
ld.w $a0, $a0, %pc_lo12(x)
|
|
||||||
syscall 0
|
syscall 0
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
@ -27,41 +25,21 @@ x:
|
||||||
/* This should produce an R_LARCH_RELATIVE in the static PIE. */
|
/* This should produce an R_LARCH_RELATIVE in the static PIE. */
|
||||||
.dword _start
|
.dword _start
|
||||||
EOF
|
EOF
|
||||||
cat > conftest2.S <<\EOF
|
|
||||||
.global f
|
|
||||||
.type f, @function
|
|
||||||
f:
|
|
||||||
/* The linker should be able to handle this and produce a PLT entry. */
|
|
||||||
la.pcrel $t0, $t0, external_func
|
|
||||||
jirl $zero, $t0, 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
libc_cv_static_pie_on_loongarch=no
|
libc_cv_static_pie_on_loongarch=no
|
||||||
if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest1 conftest1.S'
|
if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest conftest.S'
|
||||||
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
||||||
(eval $ac_try) 2>&5
|
(eval $ac_try) 2>&5
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||||
test $ac_status = 0; }; } \
|
test $ac_status = 0; }; } \
|
||||||
&& { ac_try='LC_ALL=C $READELF -Wr conftest1 | grep -q R_LARCH_RELATIVE'
|
&& { ac_try='LC_ALL=C $READELF -Wr conftest | grep -q R_LARCH_RELATIVE'
|
||||||
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
||||||
(eval $ac_try) 2>&5
|
(eval $ac_try) 2>&5
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||||
test $ac_status = 0; }; } \
|
test $ac_status = 0; }; } \
|
||||||
&& ! { ac_try='LC_ALL=C $READELF -Wl conftest1 | grep -q INTERP'
|
&& ! { ac_try='LC_ALL=C $READELF -Wl conftest | grep -q INTERP'
|
||||||
{ { 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; }; } \
|
|
||||||
&& { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -shared -nostdlib -fPIC -o conftest2.so conftest2.S'
|
|
||||||
{ { 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; }; } \
|
|
||||||
&& { ac_try='LC_ALL=C $READELF -Wr conftest2.so | grep -q 'R_LARCH_JUMP_SLOT.*external_func''
|
|
||||||
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
||||||
(eval $ac_try) 2>&5
|
(eval $ac_try) 2>&5
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
|
|
|
@ -8,19 +8,17 @@ AC_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC)
|
||||||
dnl Test if the toolchain is new enough for static PIE.
|
dnl Test if the toolchain is new enough for static PIE.
|
||||||
dnl We need a GAS supporting explicit reloc (older GAS produces stack-based
|
dnl We need a GAS supporting explicit reloc (older GAS produces stack-based
|
||||||
dnl reloc and triggers an internal error in the linker). And, we need GCC to
|
dnl reloc and triggers an internal error in the linker). And, we need GCC to
|
||||||
dnl pass the correct linker flags for static PIE. GCC >= 13 and GAS >= 2.40
|
dnl pass the correct linker flags for static PIE. We strictly require GAS >=
|
||||||
dnl satisfy the requirement, but a distro may backport static PIE support into
|
dnl 2.41 so we don't need to check the assembler capability, but we need to
|
||||||
dnl earlier GCC or Binutils releases as well.
|
dnl check if GCC is doing the correct thing.
|
||||||
AC_CACHE_CHECK([if the toolchain is sufficient to build static PIE on LoongArch],
|
AC_CACHE_CHECK([if ${CC-cc} is sufficient to build static PIE on LoongArch],
|
||||||
libc_cv_static_pie_on_loongarch, [
|
libc_cv_static_pie_on_loongarch, [
|
||||||
cat > conftest1.S <<\EOF
|
cat > conftest.S <<\EOF
|
||||||
.global _start
|
.global _start
|
||||||
.type _start, @function
|
.type _start, @function
|
||||||
_start:
|
_start:
|
||||||
li.w $a7, 93
|
li.w $a7, 93
|
||||||
/* This ensures the assembler supports explicit reloc. */
|
li.w $a0, 0
|
||||||
pcalau12i $a0, %pc_hi20(x)
|
|
||||||
ld.w $a0, $a0, %pc_lo12(x)
|
|
||||||
syscall 0
|
syscall 0
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
@ -29,21 +27,11 @@ x:
|
||||||
/* This should produce an R_LARCH_RELATIVE in the static PIE. */
|
/* This should produce an R_LARCH_RELATIVE in the static PIE. */
|
||||||
.dword _start
|
.dword _start
|
||||||
EOF
|
EOF
|
||||||
cat > conftest2.S <<\EOF
|
|
||||||
.global f
|
|
||||||
.type f, @function
|
|
||||||
f:
|
|
||||||
/* The linker should be able to handle this and produce a PLT entry. */
|
|
||||||
la.pcrel $t0, $t0, external_func
|
|
||||||
jirl $zero, $t0, 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
libc_cv_static_pie_on_loongarch=no
|
libc_cv_static_pie_on_loongarch=no
|
||||||
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest1 conftest1.S]) \
|
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest conftest.S]) \
|
||||||
&& AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest1 | grep -q R_LARCH_RELATIVE]) \
|
&& AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest | grep -q R_LARCH_RELATIVE]) \
|
||||||
&& ! AC_TRY_COMMAND([LC_ALL=C $READELF -Wl conftest1 | grep -q INTERP]) \
|
&& ! AC_TRY_COMMAND([LC_ALL=C $READELF -Wl conftest | grep -q INTERP])
|
||||||
&& AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -shared -nostdlib -fPIC -o conftest2.so conftest2.S]) \
|
|
||||||
&& AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest2.so | grep -q 'R_LARCH_JUMP_SLOT.*external_func'])
|
|
||||||
then
|
then
|
||||||
libc_cv_static_pie_on_loongarch=yes
|
libc_cv_static_pie_on_loongarch=yes
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue