summaryrefslogtreecommitdiff
path: root/gcc/configure
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2020-01-31 16:46:50 -0800
committerSandra Loosemore <sandra@codesourcery.com>2020-01-31 16:46:50 -0800
commit2d33dcfe9f0494c9b56a8d704c3d27c5a4329ebc (patch)
treef552c2ff1a82a7100904140e5c4f9f20085aee0e /gcc/configure
parent20fa702b32c7ec7a7215df322d3e8d19b79f2068 (diff)
nios2: Support for GOT-relative DW_EH_PE_datarel encoding.
On nios2-linux-gnu, there has been a long-standing bug in C++ exception handling that sometimes resulted in link errors like ../nios2-linux-gnu/bin/ld: FDE encoding in /tmp/cccfpQ2l.o(.eh_frame) prevents .eh_frame_hdr table being created when building some shared libraries or PIE executables. The root of the problem is that GCC was incorrectly emitting an absolute encoding in EH tables for PIC. This patch changes it to use either DW_EH_PE_indirect (for global) or DW_EH_PE_datarel (for local), and fixes libgcc so it can find the address of the GOT as the base address for DW_EH_PE_datarel. Complicating matters somewhat, GAS was missing support for %gotoff(symbol) relocation syntax. I have just pushed a fix for that, but I've added a configure check to test for presence of the binutils support and fall back to the current absolute encoding (which works most of the time) if it is not available. Once the fix makes it into an official binutils release it might be appropriate to make this error out instead. Since this is a wrong-code bug and affects only nios2 target, I think this is appropriate for Stage 4. I regression-tested on both nios2-linux-gnu and nios2-elf, with and without the binutils support present, before committing this. 2020-01-31 Sandra Loosemore <sandra@codesourcery.com> gcc/ * configure.ac [nios2-*-*]: Check HAVE_AS_NIOS2_GOTOFF_RELOCATION. * config.in: Regenerated. * configure: Regenerated. * config/nios2/nios2.h (ASM_PREFERRED_EH_DATA_FORMAT): Fix handling for PIC when HAVE_AS_NIOS2_GOTOFF_RELOCATION. (ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX): New. gcc/testsuite/ * g++.target/nios2/hello-pie.C: New. * g++.target/nios2/nios2.exp: New. libgcc/ * config.host [nios2-*-linux*] (tmake_file, tm_file): Adjust. * config/nios2-elf-lib.h: New. * unwind-dw2-fde-dip.c (_Unwind_IteratePhdrCallback): Use existing code for finding GOT base for nios2.
Diffstat (limited to 'gcc/configure')
-rwxr-xr-xgcc/configure37
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/configure b/gcc/configure
index 4c2c5991c0e..5fa565a40a4 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -27973,6 +27973,43 @@ $as_echo "#define HAVE_NEWLIB_NANO_FORMATTED_IO 1" >>confdefs.h
fi
;;
+ nios2-*-*)
+ # Versions 2.33 and earlier lacked support for the %gotoff relocation
+ # syntax that is documented in the ABI specification.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for support for %gotoff relocations in constant data" >&5
+$as_echo_n "checking assembler for support for %gotoff relocations in constant data... " >&6; }
+if ${gcc_cv_as_nios2_gotoff_relocation+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_nios2_gotoff_relocation=no
+ if test x$gcc_cv_as != x; then
+ $as_echo ' .extern foo
+ .data
+ .long %gotoff(foo)' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_nios2_gotoff_relocation=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_nios2_gotoff_relocation" >&5
+$as_echo "$gcc_cv_as_nios2_gotoff_relocation" >&6; }
+if test $gcc_cv_as_nios2_gotoff_relocation = yes; then
+
+$as_echo "#define HAVE_AS_NIOS2_GOTOFF_RELOCATION 1" >>confdefs.h
+
+fi
+
+ ;;
riscv*-*-*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .attribute support" >&5
$as_echo_n "checking assembler for .attribute support... " >&6; }