From 97976c0757ad3173ac00d1e32e335f3f960b0b9f Mon Sep 17 00:00:00 2001 From: Nelson Chu Date: Tue, 10 Nov 2020 19:33:38 -0800 Subject: [PATCH] RISC-V: Enable ifunc if it was supported in the binutils for linux toolchain. gcc/ * configure: Regenerated. * configure.ac: If ifunc was supported in the binutils for linux toolchain, then set enable_gnu_indirect_function to yes. --- gcc/configure | 37 +++++++++++++++++++++++++++++++++++++ gcc/configure.ac | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/gcc/configure b/gcc/configure index 9d2fd0dc30b..dbda4415a17 100755 --- a/gcc/configure +++ b/gcc/configure @@ -23407,6 +23407,43 @@ else fi +case "${target}" in + riscv*-*-linux*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker ifunc IRELATIVE support" >&5 +$as_echo_n "checking linker ifunc IRELATIVE support... " >&6; } + cat > conftest.s < /dev/null 2>&1 \ + && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \ + && $gcc_cv_readelf --relocs --wide conftest \ + | grep R_RISCV_IRELATIVE > /dev/null 2>&1; then + enable_gnu_indirect_function=yes + fi + rm -f conftest conftest.o conftest.s + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_gnu_indirect_function" >&5 +$as_echo "$enable_gnu_indirect_function" >&6; } + ;; +esac + gif=`if test x$enable_gnu_indirect_function = xyes; then echo 1; else echo 0; fi` cat >>confdefs.h <<_ACEOF diff --git a/gcc/configure.ac b/gcc/configure.ac index 73034bb902b..08f3034986e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2807,6 +2807,41 @@ Valid choices are 'yes' and 'no'.]) ;; esac], [enable_gnu_indirect_function="$default_gnu_indirect_function"]) +case "${target}" in + riscv*-*-linux*) + AC_MSG_CHECKING(linker ifunc IRELATIVE support) + cat > conftest.s < /dev/null 2>&1 \ + && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \ + && $gcc_cv_readelf --relocs --wide conftest \ + | grep R_RISCV_IRELATIVE > /dev/null 2>&1; then + enable_gnu_indirect_function=yes + fi + rm -f conftest conftest.o conftest.s + AC_MSG_RESULT($enable_gnu_indirect_function) + ;; +esac + gif=`if test x$enable_gnu_indirect_function = xyes; then echo 1; else echo 0; fi` AC_DEFINE_UNQUOTED(HAVE_GNU_INDIRECT_FUNCTION, $gif, [Define if your system supports gnu indirect functions.]) -- 2.30.2