This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Disable section merging with non-capable linkers
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 14 Jan 2006 14:03:56 +0100
- Subject: [PATCH] Disable section merging with non-capable linkers
Hi,
On x86/Solaris, if the GNU assembler and the Sun linker are used, the compiler
enables section merging. But there is a problem: the Sun linker cannot merge
sections marked with SHF_MERGE and sections not marked with SHF_MERGE so
we may end up with duplicated .debug_str sections for example.
Tested on x86/Linux and x86/Solaris. OK for mainline?
2006-01-14 Eric Botcazou <ebotcazou@adacore.com>
* configure.ac (section merging support): Additionally check
that the linker can merge marked and non-marked sections.
* configure: Regenerate.
--
Eric Botcazou
Index: configure.ac
===================================================================
--- configure.ac (revision 109470)
+++ configure.ac (working copy)
@@ -2164,11 +2164,39 @@ fi
gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
[elf,2,12,0], [--fatal-warnings],
- [.section .rodata.str, "aMS", @progbits, 1])
+ [.section .rodata.str, "aMS", @progbits, 1],
+ [gcc_cv_as_shf_merge=no
+ if test $in_tree_ld = yes ; then
+ gcc_cv_as_shf_merge=yes
+ elif test x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
+ # Check that the linker can merge marked and non-marked sections.
+ echo '.section .my_str, "aMS", @progbits, 1' > conftest1.s
+ echo '.section .my_str, "a", @progbits' > conftest2.s
+ if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
+ && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
+ && $gcc_cv_ld -o conftest conftest1.o conftest2.o > /dev/null 2>&1 \
+ && $gcc_cv_objdump -h conftest | grep my_str | wc -l | grep 1 > /dev/null; then
+ gcc_cv_as_shf_merge=yes
+ fi
+ fi])
if test $gcc_cv_as_shf_merge = no; then
gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
[elf,2,12,0], [--fatal-warnings],
- [.section .rodata.str, "aMS", %progbits, 1])
+ [.section .rodata.str, "aMS", %progbits, 1],
+ [gcc_cv_as_shf_merge=no
+ if test $in_tree_ld = yes ; then
+ gcc_cv_as_shf_merge=yes
+ elif test x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
+ # Check that the linker can merge marked and non-marked sections.
+ echo '.section .my_str, "aMS", %progbits, 1' > conftest1.s
+ echo '.section .my_str, "a", %progbits' > conftest2.s
+ if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
+ && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
+ && $gcc_cv_ld -o conftest conftest1.o conftest2.o > /dev/null 2>&1 \
+ && $gcc_cv_objdump -h conftest | grep my_str | wc -l | grep 1 > /dev/null; then
+ gcc_cv_as_shf_merge=yes
+ fi
+ fi])
fi
AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
[`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],