configure.ac 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
  2. # Local configure fragment for sysdeps/riscv/elf.
  3. # Check if static linker supports R_RISCV_ALIGN
  4. AC_CACHE_CHECK([for R_RISCV_ALIGN linker relaxation support], [libc_cv_riscv_r_align],[dnl
  5. cat > conftest.S <<EOF
  6. .align 3
  7. foo:
  8. li a0,42
  9. ret
  10. EOF
  11. libc_cv_riscv_r_align=no
  12. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o contests.o conftest.S])
  13. then
  14. libc_cv_riscv_r_align=yes
  15. fi
  16. rm -rf conftest.*])
  17. LIBC_CONFIG_VAR([riscv-r-align], [$libc_cv_riscv_r_align])
  18. dnl Test if the toolchain is new enough for static PIE.
  19. AC_CACHE_CHECK([if the toolchain is sufficient to build static PIE on RISC-V],
  20. libc_cv_static_pie_on_riscv, [
  21. cat > conftest1.S <<\EOF
  22. .globl _start
  23. .type _start, @function
  24. _start:
  25. nop
  26. .data
  27. /* This should produce an R_RISCV_RELATIVE in the static PIE. */
  28. .dword _start
  29. EOF
  30. libc_cv_static_pie_on_riscv=no
  31. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest1 conftest1.S]) \
  32. && AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest1 | grep -q R_RISCV_RELATIVE]) \
  33. && ! AC_TRY_COMMAND([LC_ALL=C $READELF -Wl conftest1 | grep -q INTERP])
  34. then
  35. libc_cv_static_pie_on_riscv=yes
  36. fi
  37. rm -rf conftest* ])
  38. if test "$libc_cv_static_pie_on_riscv" = yes; then
  39. AC_DEFINE(SUPPORT_STATIC_PIE)
  40. fi