This is the mail archive of the binutils@sources.redhat.com 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]

PATCH: Linker is broken due to _bfd_elf_merge_symbol change


On Tue, May 03, 2005 at 10:43:23PM -0700, H. J. Lu wrote:
> I got extra libstc++ failures in gcc 3.4 on ia32, ia64 and x86_64:
> 
> FAIL: 21_strings/basic_string/append/char/1.cc execution test
> FAIL: 21_strings/basic_string/append/wchar_t/1.cc execution test
> FAIL: gctest
> FAIL: 21_strings/basic_string/cons/char/1.cc execution test
> FAIL: 21_strings/basic_string/cons/wchar_t/1.cc execution test
> FAIL: 21_strings/basic_string/element_access/char/1.cc execution test
> FAIL: 21_strings/basic_string/element_access/wchar_t/1.cc execution
> test
> FAIL: 21_strings/basic_string/insert/char/1.cc execution test
> FAIL: 21_strings/basic_string/insert/wchar_t/1.cc execution test
> FAIL: 21_strings/basic_string/substr/char/1.cc execution test
> FAIL: 21_strings/basic_string/substr/wchar_t/1.cc execution test
> FAIL: 23_containers/bitset/cons/1.cc execution test
> FAIL: 23_containers/bitset/cons/6282.cc execution test
> FAIL: 23_containers/bitset/test/1.cc execution test
> FAIL: 23_containers/vector/capacity/8230.cc execution test
> FAIL: 23_containers/vector/element_access/1.cc execution test
> 
> due to
> 
> http://sourceware.org/ml/binutils/2005-05/msg00018.html
> 
> I will revert it if it is't fixed soon.
> 

This patch seems to work. Paul, I tried your testcase. It looks OK:

gnu-10:pts/3[86]> gcc x.o y.o -B/export/build/gnu/binutils-import/build-i686-linux/ld/
gnu-10:pts/3[82]> readelf -s x.o | grep foo
     7: 00000000     5 FUNC    GLOBAL DEFAULT    1 foo
gnu-10:pts/3[83]> readelf -s y.o | grep foo
     8: 00000000    40 FUNC    WEAK   DEFAULT    1 foo
gnu-10:pts/3[84]> readelf -s a.out| grep foo
    60: 08048368     5 FUNC    GLOBAL DEFAULT   12 foo

Paul, could you please provide a patch of a simple testcase for your
problem?


H.J.
----
2005-05-03  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (_bfd_elf_merge_symbol): Only skip weak definitions
	at the end, if a strong definition has already been seen.

--- bfd/elflink.c.weak	2005-05-02 08:34:48.000000000 -0700
+++ bfd/elflink.c	2005-05-03 22:47:58.000000000 -0700
@@ -1078,13 +1078,6 @@ _bfd_elf_merge_symbol (bfd *abfd,
       || h->root.type == bfd_link_hash_undefined)
     *size_change_ok = TRUE;
 
-  /* Skip weak definitions of symbols that are already defined.  */
-  if (newdef && olddef && newweak && !oldweak)
-    {
-      *skip = TRUE;
-      return TRUE;
-    }
-
   /* NEWDYNCOMMON and OLDDYNCOMMON indicate whether the new or old
      symbol, respectively, appears to be a common symbol in a dynamic
      object.  If a symbol appears in an uninitialized section, and is
@@ -1211,6 +1204,10 @@ _bfd_elf_merge_symbol (bfd *abfd,
       *size_change_ok = TRUE;
     }
 
+  /* Skip weak definitions of symbols that are already defined.  */
+  if (newdef && olddef && newweak && !oldweak)
+    *skip = TRUE;
+
   /* If the old symbol is from a dynamic object, and the new symbol is
      a definition which is not from a dynamic object, then the new
      symbol overrides the old symbol.  Symbols from regular files


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