RISC-V: Enable ifunc if it was supported in the binutils for linux toolchain.
authorNelson Chu <nelson.chu@sifive.com>
Wed, 11 Nov 2020 03:33:38 +0000 (19:33 -0800)
committerJim Wilson <jimw@sifive.com>
Thu, 12 Nov 2020 21:47:16 +0000 (13:47 -0800)
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
gcc/configure.ac

index 9d2fd0dc30bc33136810628e2abc58157f1c6335..dbda4415a1714d66112cda19e75468f1e34d0c4a 100755 (executable)
@@ -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 <<EOF
+       .text
+       .type   foo_resolver, @function
+foo_resolver:
+       ret
+       .size   foo_resolver, .-foo_resolver
+
+       .globl  foo
+       .type   foo, %gnu_indirect_function
+       .set    foo, foo_resolver
+
+       .globl  bar
+       .type   bar, @function
+bar:
+       call    foo
+       ret
+       .size   bar, .-bar
+EOF
+    if test x$gcc_cv_as != x \
+       && test x$gcc_cv_ld != x \
+       && test x$gcc_cv_readelf != x \
+       && $gcc_cv_as -o conftest.o 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
index 73034bb902b9de17735d88aecf566255ab833191..08f3034986ec5fa4eab0c98ee9e7c18052881156 100644 (file)
@@ -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 <<EOF
+       .text
+       .type   foo_resolver, @function
+foo_resolver:
+       ret
+       .size   foo_resolver, .-foo_resolver
+
+       .globl  foo
+       .type   foo, %gnu_indirect_function
+       .set    foo, foo_resolver
+
+       .globl  bar
+       .type   bar, @function
+bar:
+       call    foo
+       ret
+       .size   bar, .-bar
+EOF
+    if test x$gcc_cv_as != x \
+       && test x$gcc_cv_ld != x \
+       && test x$gcc_cv_readelf != x \
+       && $gcc_cv_as -o conftest.o 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.])