This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Detect problematic linker for HAVE_LD_EH_GC_SECTIONS

The patch

2006-10-28  Eric Botcazou  <>

	* except.h (output_function_exception_table): Add 'const char*' param.
	* except.c (switch_to_exception_section): Add 'const char*' param.
	If named sections are supported and HAVE_LD_EH_GC_SECTIONS is defined
	and flag_function_sections is set, use a function-specific section.
	(output_function_exception_table): Add 'const char*' param.
	Adjust call to switch_to_exception_section.
	* final.c (rest_of_handle_final): Adjust calls to
	* (HAVE_LD_EH_GC_SECTIONS): New check.
	* Regenerate.
	* configure: Likewise.

works in conjunction with a recent GNU linker (2.17) to improve --gc-sections 
for languages using EH.  As discovered by early FC6 users, there is a problem 
if COMDAT groups are disabled.  The linker fix has been in for a few days:
and the attached patch simply disables compiler support with a buggy linker.

According to Dave Anglin, the feature runs into another binutils bug on 
HP-PA/Linux so the patch additionally disables it on this platform.

Bootstrapped/regtested on i586-suse-linux, tested with buggy and non-buggy 
linker, with and without COMDAT groups, applied to mainline as obvious.

2006-12-21  Eric Botcazou  <>

	PR other/29639
	* (HAVE_LD_EH_GC_SECTIONS): Check that exception tables
	are kept for .gnu.linkonce.t sections if COMDAT groups are disabled.
	* configure: Regenerate.

Eric Botcazou
---	(revision 120045)
+++	(working copy)
@@ -3192,10 +3192,46 @@ EOF
     elif $gcc_cv_objdump -h conftest | grep gcc_except_table > /dev/null; then
+      # If no COMDAT groups, the compiler will emit .gnu.linkonce.t. sections.
+      if test x$gcc_cv_as_comdat_group != xyes; then
+	gcc_cv_ld_eh_gc_sections=no
+	cat > conftest.s <<EOF
+	.section	.text
+.globl _start
+        .type _start, @function
+	.long foo
+	.size _start, .-_start
+	.section,"ax",@progbits
+	.type foo, @function
+	.long 0
+	.size foo, .-foo
+	.section,"a",@progbits
+	.long 0
+	.section	.eh_frame,"a",@progbits
+	.long .L0
+	if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+	  if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
+	       | grep "gc-sections option ignored" > /dev/null; then
+	    gcc_cv_ld_eh_gc_sections=no
+	  elif $gcc_cv_objdump -h conftest | grep gcc_except_table > /dev/null; then
+	    gcc_cv_ld_eh_gc_sections=yes
+	  fi
+	fi
+      fi
   rm -f conftest.s conftest.o conftest
+case "$target" in
+  hppa*-*-linux*)
+    # ??? This apparently exposes a binutils bug with PC-relative relocations.
+    gcc_cv_ld_eh_gc_sections=no
+    ;;
 if test x$gcc_cv_ld_eh_gc_sections = xyes; then
   [Define if your linker supports garbage collection of

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]