diff options
author | Xi Ruoyao <xry111@xry111.site> | 2023-08-27 00:36:49 +0800 |
---|---|---|
committer | caiyinyu <caiyinyu@loongson.cn> | 2023-08-29 10:35:38 +0800 |
commit | e757412c3e8a59cd93230414800250b38aeddf6c (patch) | |
tree | 986e8f60a2561ccaf038e3b3a35edddd73289d4f /sysdeps/loongarch/configure.ac | |
parent | 42c960a4f1052a71d928a1c554f5d445b00e61f7 (diff) | |
download | glibc-e757412c3e8a59cd93230414800250b38aeddf6c.tar.gz glibc-e757412c3e8a59cd93230414800250b38aeddf6c.tar.xz glibc-e757412c3e8a59cd93230414800250b38aeddf6c.zip |
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>
Diffstat (limited to 'sysdeps/loongarch/configure.ac')
-rw-r--r-- | sysdeps/loongarch/configure.ac | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac index 989287c6d2..28a8ae5486 100644 --- a/sysdeps/loongarch/configure.ac +++ b/sysdeps/loongarch/configure.ac @@ -8,19 +8,17 @@ AC_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC) 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 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 satisfy the requirement, but a distro may backport static PIE support into -dnl earlier GCC or Binutils releases as well. -AC_CACHE_CHECK([if the toolchain is sufficient to build static PIE on LoongArch], +dnl pass the correct linker flags for static PIE. We strictly require GAS >= +dnl 2.41 so we don't need to check the assembler capability, but we need to +dnl check if GCC is doing the correct thing. +AC_CACHE_CHECK([if ${CC-cc} is sufficient to build static PIE on LoongArch], libc_cv_static_pie_on_loongarch, [ - cat > conftest1.S <<\EOF + cat > conftest.S <<\EOF .global _start .type _start, @function _start: li.w $a7, 93 - /* This ensures the assembler supports explicit reloc. */ - pcalau12i $a0, %pc_hi20(x) - ld.w $a0, $a0, %pc_lo12(x) + li.w $a0, 0 syscall 0 .data @@ -29,21 +27,11 @@ x: /* This should produce an R_LARCH_RELATIVE in the static PIE. */ .dword _start 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 - if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest1 conftest1.S]) \ - && AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest1 | grep -q R_LARCH_RELATIVE]) \ - && ! AC_TRY_COMMAND([LC_ALL=C $READELF -Wl conftest1 | 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']) + 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 conftest | grep -q R_LARCH_RELATIVE]) \ + && ! AC_TRY_COMMAND([LC_ALL=C $READELF -Wl conftest | grep -q INTERP]) then libc_cv_static_pie_on_loongarch=yes fi |