except.h (output_function_exception_table): Add 'const char*' param.
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 28 Oct 2006 18:11:28 +0000 (18:11 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 28 Oct 2006 18:11:28 +0000 (18:11 +0000)
* 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
output_function_exception_table.
* configure.ac (HAVE_LD_EH_GC_SECTIONS): New check.
* config.in: Regenerate.
* configure: Likewise.

From-SVN: r118107

gcc/ChangeLog
gcc/config.in
gcc/configure
gcc/configure.ac
gcc/except.c
gcc/except.h
gcc/final.c

index fe590bf2ac28fb7f1d8cf64968999d9ed473c400..344caf396e059c4192e6efc79d4a5e81d19ab8e4 100644 (file)
@@ -1,3 +1,17 @@
+2006-10-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * 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
+       output_function_exception_table.
+       * configure.ac (HAVE_LD_EH_GC_SECTIONS): New check.
+       * config.in: Regenerate.
+       * configure: Likewise.
+
 2006-10-28  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/26899
index 65b583bea4e3d98eac50363ff6b25a17a385052d..91146bb21428d3753eaf5ad1dfc5a100c605af62 100644 (file)
 /* Define if your linker supports --eh-frame-hdr option. */
 #undef HAVE_LD_EH_FRAME_HDR
 
+/* Define if your linker supports garbage collection of sections in presence
+   of EH frames. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LD_EH_GC_SECTIONS
+#endif
+
+
 /* Define if your PowerPC64 linker only needs function descriptor syms. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LD_NO_DOT_SYMS
index 2eb6bb77faaef90e2296d4b7c4a46cf422a988cd..54a2a17feca781c8e207d6bf75568c526f15685a 100755 (executable)
 echo "$as_me:$LINENO: result: $gcc_cv_ld_pie" >&5
 echo "${ECHO_T}$gcc_cv_ld_pie" >&6
 
+echo "$as_me:$LINENO: checking linker EH-compatible garbage collection of sections" >&5
+echo $ECHO_N "checking linker EH-compatible garbage collection of sections... $ECHO_C" >&6
+gcc_cv_ld_eh_gc_sections=no
+if test $in_tree_ld = yes ; then
+  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 17 -o "$gcc_cv_gld_major_version" -gt 2 \
+     && test $in_tree_ld_is_elf = yes; then
+    gcc_cv_ld_eh_gc_sections=yes
+  fi
+elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
+  cat > conftest.s <<EOF
+       .section        .text
+.globl _start
+        .type _start, @function
+_start:
+       .long foo
+       .size _start, .-_start
+       .section        .text.foo,"ax",@progbits
+       .type foo, @function
+foo:
+       .long 0
+       .size foo, .-foo
+       .section        .gcc_except_table.foo,"a",@progbits
+.L0:
+       .long 0
+       .section        .eh_frame,"a",@progbits
+       .long .L0
+EOF
+  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
+  rm -f conftest.s conftest.o conftest
+fi
+if test x$gcc_cv_ld_eh_gc_sections = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LD_EH_GC_SECTIONS 1
+_ACEOF
+
+fi
+echo "$as_me:$LINENO: result: $gcc_cv_ld_eh_gc_sections" >&5
+echo "${ECHO_T}$gcc_cv_ld_eh_gc_sections" >&6
+
 # --------
 # UNSORTED
 # --------
index 7c8b3af99667e674615557a4a61b9faa213486d7..1dafd858f7b61763735b0349d1bbbbe4753fd762 100644 (file)
@@ -3119,6 +3119,49 @@ if test x"$gcc_cv_ld_pie" = xyes; then
 fi
 AC_MSG_RESULT($gcc_cv_ld_pie)
 
+AC_MSG_CHECKING(linker EH-compatible garbage collection of sections)
+gcc_cv_ld_eh_gc_sections=no
+if test $in_tree_ld = yes ; then
+  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 17 -o "$gcc_cv_gld_major_version" -gt 2 \
+     && test $in_tree_ld_is_elf = yes; then
+    gcc_cv_ld_eh_gc_sections=yes
+  fi
+elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
+  cat > conftest.s <<EOF
+       .section        .text
+.globl _start
+        .type _start, @function
+_start:
+       .long foo
+       .size _start, .-_start
+       .section        .text.foo,"ax",@progbits
+       .type foo, @function
+foo:
+       .long 0
+       .size foo, .-foo
+       .section        .gcc_except_table.foo,"a",@progbits
+.L0:
+       .long 0
+       .section        .eh_frame,"a",@progbits
+       .long .L0
+EOF
+  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
+  rm -f conftest.s conftest.o conftest
+fi
+if test x$gcc_cv_ld_eh_gc_sections = xyes; then
+       AC_DEFINE(HAVE_LD_EH_GC_SECTIONS, 1,
+  [Define if your linker supports garbage collection of
+   sections in presence of EH frames.])
+fi
+AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections)
+
 # --------
 # UNSORTED
 # --------
index 30dafbb8073f24260d2a3e9c1d7d88a41997a133..306916968e8189582d1560b6d8389d2b7a8cc236 100644 (file)
@@ -3520,7 +3520,7 @@ sjlj_output_call_site_table (void)
 /* Switch to the section that should be used for exception tables.  */
 
 static void
-switch_to_exception_section (void)
+switch_to_exception_section (const char * ARG_UNUSED (fnname))
 {
   if (exception_section == 0)
     {
@@ -3539,6 +3539,16 @@ switch_to_exception_section (void)
            }
          else
            flags = SECTION_WRITE;
+#ifdef HAVE_LD_EH_GC_SECTIONS
+         if (flag_function_sections)
+           {
+             char *section_name = xmalloc (strlen (fnname) + 32);
+             sprintf (section_name, ".gcc_except_table.%s", fnname);
+             exception_section = get_section (section_name, flags, NULL);
+             free (section_name);
+           }
+         else
+#endif
          exception_section = get_section (".gcc_except_table", flags, NULL);
        }
       else
@@ -3599,7 +3609,7 @@ output_ttype (tree type, int tt_format, int tt_format_size)
 }
 
 void
-output_function_exception_table (void)
+output_function_exception_table (const char * ARG_UNUSED (fnname))
 {
   int tt_format, cs_format, lp_format, i, n;
 #ifdef HAVE_AS_LEB128
@@ -3627,7 +3637,7 @@ output_function_exception_table (void)
   /* Note that varasm still thinks we're in the function's code section.
      The ".endp" directive that will immediately follow will take us back.  */
 #else
-  switch_to_exception_section ();
+  switch_to_exception_section (fnname);
 #endif
 
   /* If the target wants a label to begin the table, emit it here.  */
index 1f96477f2e0366d5320a368f73e08b4e0fd1b494..5efad71647fe9014acbc46e30dac0c710f2bad65 100644 (file)
@@ -68,7 +68,7 @@ extern void convert_from_eh_region_ranges (void);
 extern unsigned int convert_to_eh_region_ranges (void);
 extern void find_exception_handler_labels (void);
 extern bool current_function_has_exception_handlers (void);
-extern void output_function_exception_table (void);
+extern void output_function_exception_table (const char *);
 
 extern void expand_builtin_unwind_init (void);
 extern rtx expand_builtin_eh_return_data_regno (tree);
index d64f0c3e2281f53bd886ffc6368fcd50523cbac6..9e35d535d34ad17d9516fd409d805f127e884eec 100644 (file)
@@ -3920,14 +3920,14 @@ rest_of_handle_final (void)
 #ifdef TARGET_UNWIND_INFO
   /* ??? The IA-64 ".handlerdata" directive must be issued before
      the ".endp" directive that closes the procedure descriptor.  */
-  output_function_exception_table ();
+  output_function_exception_table (fnname);
 #endif
 
   assemble_end_function (current_function_decl, fnname);
 
 #ifndef TARGET_UNWIND_INFO
   /* Otherwise, it feels unclean to switch sections in the middle.  */
-  output_function_exception_table ();
+  output_function_exception_table (fnname);
 #endif
 
   user_defined_section_attribute = false;