summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-28 15:36:37 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-28 15:36:37 +0000
commit34edf61bbe1c8822722e8c2795c842d4f33d6cbf (patch)
treebcf30f81c91016458a27aa522a244c86f6230419
parent9b971ff831d21ce2bc91979f68d5d167c136990c (diff)
downloadgcc-34edf61bbe1c8822722e8c2795c842d4f33d6cbf.tar.gz
PR middle-end/46790
* configure.ac (HAVE_LD_EH_GC_SECTIONS_BUG): New test. * configure: Regenerated. * config.in: Regenerated. * varasm.c (default_function_section): Return NULL if HAVE_LD_EH_GC_SECTIONS_BUG and decl has implicit section name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170565 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config.in7
-rwxr-xr-xgcc/configure47
-rw-r--r--gcc/configure.ac45
-rw-r--r--gcc/varasm.c9
5 files changed, 118 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cbad9a2e313..7c3d538e4e3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2011-02-28 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/46790
+ * configure.ac (HAVE_LD_EH_GC_SECTIONS_BUG): New test.
+ * configure: Regenerated.
+ * config.in: Regenerated.
+ * varasm.c (default_function_section): Return NULL
+ if HAVE_LD_EH_GC_SECTIONS_BUG and decl has implicit
+ section name.
+
2011-02-28 Martin Jambor <mjambor@suse.cz>
* ipa-inline.c (cgraph_decide_inlining_of_small_functions): Fix
diff --git a/gcc/config.in b/gcc/config.in
index f3b0eee3126..584ec65b2b7 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1171,6 +1171,13 @@
#endif
+/* Define if your linker has buggy garbage collection of sections support when
+ .text.startup.foo like sections are used. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LD_EH_GC_SECTIONS_BUG
+#endif
+
+
/* Define if your PowerPC64 linker supports a large TOC. */
#ifndef USED_FOR_TARGET
#undef HAVE_LD_LARGE_TOC
diff --git a/gcc/configure b/gcc/configure
index 2da3716d834..a4549469816 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -25445,6 +25445,53 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_eh_gc_sections" >&5
$as_echo "$gcc_cv_ld_eh_gc_sections" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker EH garbage collection of sections bug" >&5
+$as_echo_n "checking linker EH garbage collection of sections bug... " >&6; }
+gcc_cv_ld_eh_gc_sections_bug=no
+if test $in_tree_ld = yes ; then
+ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -lt 19 -o "$gcc_cv_gld_major_version" -lt 2 \
+ && test $in_tree_ld_is_elf = yes; then
+ gcc_cv_ld_eh_gc_sections_bug=yes
+ fi
+elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x -a x$gcc_cv_as_comdat_group = xyes; then
+ gcc_cv_ld_eh_gc_sections_bug=yes
+ cat > conftest.s <<EOF
+ .section .text
+.globl _start
+ .type _start, @function
+_start:
+ .long foo
+ .size _start, .-_start
+ .section .text.startup.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
+ :
+ elif $gcc_cv_objdump -h conftest 2> /dev/null \
+ | grep gcc_except_table > /dev/null; then
+ gcc_cv_ld_eh_gc_sections_bug=no
+ fi
+ fi
+ rm -f conftest.s conftest.o conftest
+fi
+if test x$gcc_cv_ld_eh_gc_sections_bug = xyes; then
+
+$as_echo "#define HAVE_LD_EH_GC_SECTIONS_BUG 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_eh_gc_sections_bug" >&5
+$as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
+
# --------
# UNSORTED
# --------
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 0c065e0de9b..03a8cef47d6 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4097,6 +4097,51 @@ if test x$gcc_cv_ld_eh_gc_sections = xyes; then
fi
AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections)
+AC_MSG_CHECKING(linker EH garbage collection of sections bug)
+gcc_cv_ld_eh_gc_sections_bug=no
+if test $in_tree_ld = yes ; then
+ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -lt 19 -o "$gcc_cv_gld_major_version" -lt 2 \
+ && test $in_tree_ld_is_elf = yes; then
+ gcc_cv_ld_eh_gc_sections_bug=yes
+ fi
+elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x -a x$gcc_cv_as_comdat_group = xyes; then
+ gcc_cv_ld_eh_gc_sections_bug=yes
+ cat > conftest.s <<EOF
+ .section .text
+.globl _start
+ .type _start, @function
+_start:
+ .long foo
+ .size _start, .-_start
+ .section .text.startup.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
+ :
+ elif $gcc_cv_objdump -h conftest 2> /dev/null \
+ | grep gcc_except_table > /dev/null; then
+ gcc_cv_ld_eh_gc_sections_bug=no
+ fi
+ fi
+ rm -f conftest.s conftest.o conftest
+fi
+if test x$gcc_cv_ld_eh_gc_sections_bug = xyes; then
+ AC_DEFINE(HAVE_LD_EH_GC_SECTIONS_BUG, 1,
+ [Define if your linker has buggy garbage collection of
+ sections support when .text.startup.foo like sections are used.])
+fi
+AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_bug)
+
# --------
# UNSORTED
# --------
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 76675cdeb0d..9887fe41b66 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -554,6 +554,15 @@ section *
default_function_section (tree decl, enum node_frequency freq,
bool startup, bool exit)
{
+#if defined HAVE_LD_EH_GC_SECTIONS && defined HAVE_LD_EH_GC_SECTIONS_BUG
+ /* Old GNU linkers have buggy --gc-section support, which sometimes
+ results in .gcc_except_table* sections being garbage collected. */
+ if (decl
+ && DECL_SECTION_NAME (decl)
+ && DECL_HAS_IMPLICIT_SECTION_NAME_P (decl))
+ return NULL;
+#endif
+
if (!flag_reorder_functions
|| !targetm.have_named_sections)
return NULL;