This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR ld/3666: Comdat/linkonce doesn't merge symbol visibility
On Wed, Dec 06, 2006 at 07:20:54AM -0800, H. J. Lu wrote:
> On Wed, Dec 06, 2006 at 03:18:12PM +0000, Paul Brook wrote:
> > On Wednesday 06 December 2006 15:14, H. J. Lu wrote:
> > > We shouldn't ignore symbol visibility for symbols from discarded
> > > section.
> >
> > Really? Why not?
>
> See
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20218
>
>
Here is the one with testcase. Basically, file order shouldn't affect
linking success or fail.
H.J.
---
bfd/
2006-12-06 H.J. Lu <hjl@gnu.org>
PR ld/3666
* elflink.c (elf_link_add_object_symbols): Keep symbol
visibility for symbols from discarded section.
ld/testsuite/
2006-12-06 H.J. Lu <hjl@gnu.org>
PR ld/3666
* ld-elf/group3a.d: New file.
* ld-elf/group3a.s: Likewise.
* ld-elf/group3b.d: Likewise.
* ld-elf/group3b.s: Likewise.
--- binutils/bfd/elflink.c.merge 2006-12-06 06:43:24.000000000 -0800
+++ binutils/bfd/elflink.c 2006-12-06 07:31:35.000000000 -0800
@@ -3702,12 +3702,10 @@ elf_link_add_object_symbols (bfd *abfd,
sec = bfd_abs_section_ptr;
else if (sec->kept_section)
{
- /* Symbols from discarded section are undefined, and have
- default visibility. */
+ /* Symbols from discarded section are undefined. We keep
+ its visibility. */
sec = bfd_und_section_ptr;
isym->st_shndx = SHN_UNDEF;
- isym->st_other = (STV_DEFAULT
- | (isym->st_other & ~ ELF_ST_VISIBILITY (-1)));
}
else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
value -= sec->vma;
--- binutils/ld/testsuite/ld-elf/group3a.d.merge 2006-12-06 07:18:35.000000000 -0800
+++ binutils/ld/testsuite/ld-elf/group3a.d 2006-12-06 07:29:37.000000000 -0800
@@ -0,0 +1,8 @@
+#source: group3a.s
+#source: group3b.s
+#ld: -T group.ld
+#readelf: -s
+Symbol table '.symtab' contains .* entries:
+#...
+ .*: 0[0]*1000 0 OBJECT GLOBAL HIDDEN . foo
+#...
--- binutils/ld/testsuite/ld-elf/group3a.s.merge 2006-12-06 07:18:55.000000000 -0800
+++ binutils/ld/testsuite/ld-elf/group3a.s 2006-12-06 07:24:42.000000000 -0800
@@ -0,0 +1,5 @@
+ .section .data,"awG",%progbits,foo_group,comdat
+ .globl foo
+ .type foo,%object
+foo:
+ .word 0
--- binutils/ld/testsuite/ld-elf/group3b.d.merge 2006-12-06 07:29:58.000000000 -0800
+++ binutils/ld/testsuite/ld-elf/group3b.d 2006-12-06 07:30:07.000000000 -0800
@@ -0,0 +1,8 @@
+#source: group3b.s
+#source: group3a.s
+#ld: -T group.ld
+#readelf: -s
+Symbol table '.symtab' contains .* entries:
+#...
+ .*: 0[0]*1000 0 OBJECT GLOBAL HIDDEN . foo
+#...
--- binutils/ld/testsuite/ld-elf/group3b.s.merge 2006-12-06 07:24:54.000000000 -0800
+++ binutils/ld/testsuite/ld-elf/group3b.s 2006-12-06 07:28:07.000000000 -0800
@@ -0,0 +1,6 @@
+ .section .data,"awG",%progbits,foo_group,comdat
+ .hidden foo
+ .globl foo
+ .type foo,%object
+foo:
+ .word 0