This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] Restore .gnu.linkonce.r. g++-3.4 linking
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: binutils at sourceware dot org
- Date: Thu, 23 Oct 2008 01:59:14 +0200
- Subject: [patch] Restore .gnu.linkonce.r. g++-3.4 linking
Hi,
the attached testcase reproduces a regression of ld on the output of g++-3.4:
binutils-2.15.92.0.2:
`.gnu.linkonce.t.foo' referenced in section `.gnu.linkonce.r.foo' of
/tmp/2j.o: defined in discarded section `.gnu.linkonce.t.foo' of /tmp/2j.o
output produced (.rela.gnu.linkonce.r.foo present with cleared relocations)
CVS HEAD:
`.gnu.linkonce.t.foo' referenced in section `.gnu.linkonce.r.foo' of
/tmp/2j.o: defined in discarded section `.gnu.linkonce.t.foo' of /tmp/2j.o
no output
patched CVS HEAD:
(no warnings)
output produced (.rela.gnu.linkonce.r.foo present with cleared relocations)
/* g++-3.x specific - before COMDAT groups were supported. .gnu.linkonce.r.*
is present only sometimes, depending on the compilation options.
.gnu.linkonce.r.* is like .rodata for its .gnu.linkonce.t.* so there is no
use for it if it did not exist in the file from which we chose
.gnu.linkonce.t.* as the one not being discarded. We would also fail to
PRETEND the symbols as the other .gnu.linkonce.r.* section has different
size. */
g++-3.x introduced .gnu.linkonce.r.* by:
http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00653.html
It would be best to discard such .gnu.linkonce.r.* section if its
.gnu.linkonce.t.* counterpart is discarded but I do not find it so important
as the whole patch is just for the temporary backward compatibility.
http://people.redhat.com/jkratoch/binutils-rbind.patch (best to be in g++-3.4)
http://people.redhat.com/jkratoch/binutils-rdiscard.patch
No regressions but the new testcase fails for (expected - as the other
linkonce* testcases also fail there due to the local label `1'):
hppa64-hp-hpux11.23 mmix-elf shl-unknown-netbsdelf1.6T
Thanks,
Jan
2008-10-22 Jan Kratochvil <jan.kratochvil@redhat.com>
Support pre-COMDAT g++-3.4 possibly missing `.gnu.linkonce.r.*'.
* elflink.c (_bfd_elf_default_action_discarded <.gnu.linkonce.r.>): New.
2008-10-22 Jan Kratochvil <jan.kratochvil@redhat.com>
* ld-elf/linkoncerdiff.d, ld-elf/linkoncerdiff1.s,
ld-elf/linkoncerdiff2.s: New.
--- bfd/elflink.c 20 Oct 2008 10:57:33 -0000 1.315
+++ bfd/elflink.c 22 Oct 2008 21:50:58 -0000
@@ -8811,6 +8811,16 @@ _bfd_elf_default_action_discarded (asect
if (strcmp (".gcc_except_table", sec->name) == 0)
return 0;
+ /* g++-3.x specific - before COMDAT groups were supported. .gnu.linkonce.r.*
+ is present only sometimes, depending on the compilation options.
+ .gnu.linkonce.r.* is like .rodata for its .gnu.linkonce.t.* so there is no
+ use for it if it did not exist in the file from which we chose
+ .gnu.linkonce.t.* as the one not being discarded. We would also fail to
+ PRETEND the symbols as the other .gnu.linkonce.r.* section has different
+ size. */
+ if (CONST_STRNEQ (sec->name, ".gnu.linkonce.r."))
+ return 0;
+
return COMPLAIN | PRETEND;
}
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/linkoncerdiff.d 22 Oct 2008 21:51:02 -0000
@@ -0,0 +1,5 @@
+#source: linkoncerdiff1.s
+#source: linkoncerdiff2.s
+#ld: -r
+#objdump: -r
+#pass
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/linkoncerdiff1.s 22 Oct 2008 21:51:02 -0000
@@ -0,0 +1,3 @@
+ .section .gnu.linkonce.t.foo, "a", %progbits
+1:
+sym:
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/linkoncerdiff2.s 22 Oct 2008 21:51:02 -0000
@@ -0,0 +1,8 @@
+ .section .gnu.linkonce.t.foo, "a", %progbits
+1:
+sym:
+ .long 0
+
+ .section .gnu.linkonce.r.foo, "a", %progbits
+ .long 1b
+ .long sym