This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR ld/15167: ld merges gnu_unique def and normal ref into normal symbol


On Thu, Feb 21, 2013 at 3:16 PM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Feb 21, 2013 at 11:44:33AM -0800, H.J. Lu wrote:
>> --- a/bfd/elflink.c
>> +++ b/bfd/elflink.c
>> @@ -4197,7 +4197,7 @@ error_free_dyn:
>>       h = (struct elf_link_hash_entry *) h->root.u.i.link;
>>
>>        *sym_hash = h;
>> -      if (is_elf_hash_table (htab))
>> +      if (is_elf_hash_table (htab) && definition)
>>       h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
>>
>>        new_weak = (flags & BSF_WEAK) != 0;
>
> Let's move setting of h->unique_global down to where other flags are
> set.  Where h->target_internal is set looks ideal.
>
> Also, why is h->unique_global being set in _bfd_elf_merge_symbol?
> That doesn't look correct to me.

Like this?


-- 
H.J.
---
bfd/

2013-02-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/15167
	* elf64-ia64-vms.c (elf64_vms_link_add_object_symbols): Set
	unique_global only for definition.
	* elflink.c (_bfd_elf_merge_symbol): Don't set unique_global
	here.
	(elf_link_add_object_symbols): Set unique_global only
	for definition.

ld/

2013-02-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/15141
	* plugin.c (plugin_notice): Also trace symbol from the IR bfd.

diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 6747e0c..82fd646 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -5046,7 +5046,8 @@ error_free_dyn:
 	h = (struct elf_link_hash_entry *) h->root.u.i.link;

       *sym_hash = h;
-      h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
+      if (definition)
+	h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;

       /* Set the alignment of a common symbol.  */
       if ((common || bfd_is_com_section (sec))
diff --git a/bfd/elflink.c b/bfd/elflink.c
index e9ed760..ba65f21 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1262,9 +1262,6 @@ _bfd_elf_merge_symbol (bfd *abfd,
       return TRUE;
     }

-  if (bind == STB_GNU_UNIQUE)
-    h->unique_global = 1;
-
   /* If a new weak symbol definition comes from a regular file and the
      old symbol comes from a dynamic library, we treat the new one as
      strong.  Similarly, an old weak symbol definition from a regular
@@ -4197,8 +4194,6 @@ error_free_dyn:
 	h = (struct elf_link_hash_entry *) h->root.u.i.link;

       *sym_hash = h;
-      if (is_elf_hash_table (htab))
-	h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;

       new_weak = (flags & BSF_WEAK) != 0;
       new_weakdef = FALSE;
@@ -4425,7 +4420,10 @@ error_free_dyn:
 	    dynsym = FALSE;

 	  if (definition)
-	    h->target_internal = isym->st_target_internal;
+	    {
+	      h->target_internal = isym->st_target_internal;
+	      h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
+	    }

 	  /* Check to see if we need to add an indirect symbol for
 	     the default name.  */
diff --git a/ld/testsuite/ld-unique/unique.exp
b/ld/testsuite/ld-unique/unique.exp
index 646e5ec..9bc65e0 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -145,6 +145,12 @@ if ![default_ld_link $ld
"tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_emp
     set fails [expr $fails + 1]
 }

+# Create shared library containing unique symbol with reference.
+if ![ld_simple_link $ld "tmpdir/libunique_shared_ref.so" "-shared
tmpdir/unique_shared.o tmpdir/unique_empty.o"] {
+    fail "Could not create a shared library containing an unique
symbol with reference"
+    set fails [expr $fails + 1]
+}
+
 if { $fails != 0 } {
     return
 }
@@ -220,6 +226,17 @@ if {[contains_unique_symbol
tmpdir/libunique_shared.so] != 1} {
     set fails [expr $fails + 1]
 }

+# Check the unique shared library with reference.
+if {! [check_osabi tmpdir/libunique_shared_ref.so {UNIX - GNU}]} {
+    fail "Shared library containing unique with reference does not
have an OS/ABI field of GNU"
+    set fails [expr $fails + 1]
+}
+
+if {[contains_unique_symbol tmpdir/libunique_shared_ref.so] != 1} {
+    fail "Shared library containing unique with reference does not
contain an UNIQUE symbol"
+    set fails [expr $fails + 1]
+}
+
 if { $fails == 0 } {
   pass "Checking unique PIC object"
 }
@@ -245,6 +262,7 @@ if { $verbose < 1 } {
     remote_file host delete "tmpdir/unique.o"
     remote_file host delete "tmpdir/unique_shared.o"
     remote_file host delete "tmpdir/libunique_shared.so"
+    remote_file host delete "tmpdir/libunique_shared_ref.so"
     remote_file host delete "tmpdir/unique_prog"
     remote_file host delete "tmpdir/unique_shared_prog"
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]