This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR ld/6931: COMDAT group is broken
On Sat, Oct 04, 2008 at 03:43:42PM +0930, Alan Modra wrote:
> On Fri, Oct 03, 2008 at 12:41:01PM -0700, H.J. Lu wrote:
> > It is unsafe to use an existing section symbol as group signature
> > since "ld -r" may change section symbol if there is a duplicate.
> > This patch disallows using section symbol as group signature.
> > OK to install?
>
> This fixes the latest problem HJ has found with section groups and
> ld -r. To stop ld -r merging sections that are part of a group, ld
> generated unique names for them. If a renamed section symbol is used
> as the group signature, then the group is broken. So, don't rename
> sections. This was suprisingly easy to do with the existing SPECIAL
> section support.
>
I checked in this patch to add a testcase.
Thanks.
H.J.
----
2008-10-04 H.J. Lu <hongjiu.lu@intel.com>
PR ld/6931
* ld-elf/group7.d: New.
--- ld-elf/group7.d.grp 2008-10-04 07:49:53.000000000 -0700
+++ ld-elf/group7.d 2008-10-04 07:52:00.000000000 -0700
@@ -0,0 +1,28 @@
+#source: ../../../binutils/testsuite/binutils-all/group.s
+#source: ../../../binutils/testsuite/binutils-all/group-2.s
+#source: ../../../binutils/testsuite/binutils-all/group-3.s
+#source: ../../../binutils/testsuite/binutils-all/group-4.s
+#ld: -r
+#readelf: -g --wide
+
+#...
+COMDAT group section \[[ 0-9]+\] `foo_group' \[foo_group\] contains 2 sections:
+ \[Index\] Name
+ \[[ 0-9]+\] .text.foo
+ \[[ 0-9]+\] .data.foo
+#...
+COMDAT group section \[[ 0-9]+\] `.group' \[.text.foo\] contains 2 sections:
+ \[Index\] Name
+ \[[ 0-9]+\] .text.foo
+ \[[ 0-9]+\] .data.bar
+#...
+COMDAT group section \[[ 0-9]+\] `.group' \[foo3\] contains 2 sections:
+ \[Index\] Name
+ \[[ 0-9]+\] .text.foo3
+ \[[ 0-9]+\] .data.bar3
+#...
+COMDAT group section \[[ 0-9]+\] `.group' \[foo4\] contains 2 sections:
+ \[Index\] Name
+ \[[ 0-9]+\] .text.foo4
+ \[[ 0-9]+\] .data.foo4
+#pass