PATCH: Fix ld/113: Linker sagfaults when weak undef symbol changes size

H. J. Lu hjl@lucon.org
Wed Apr 14 21:48:00 GMT 2004


Alan, now I know why I added newdef and olddef to the tests.

http://sources.redhat.com/ml/binutils/2004-03/msg00449.html



H.J.
-------------- next part --------------
2004-04-14  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (_bfd_elf_merge_symbol): Change weak to strong only
	if it is a definition.

--- bfd/elflink.c.weak	2004-04-14 14:35:32.000000000 -0700
+++ bfd/elflink.c	2004-04-14 14:40:27.000000000 -0700
@@ -893,10 +893,16 @@ _bfd_elf_merge_symbol (bfd *abfd,
      strong when the new symbol comes from a dynamic library.  Further,
      an old weak symbol from a dynamic library is treated as strong if
      the new symbol is from a dynamic library.  This reflects the way
-     glibc's ld.so works.  */
-  if (!newdyn && olddyn)
+     glibc's ld.so works.
+   
+     We treat a weak symbol as strong only when it is a definition.
+     Otherwise, the type/size change won't work right. We can't move
+     those codes after the type/size change since we don't want to
+     change the type/size change when a weak definition is treated
+     as strong.  */
+  if (newdef && !newdyn && olddyn)
     newweak = FALSE;
-  if (newdyn)
+  if (olddef && newdyn)
     oldweak = FALSE;
 
   /* It's OK to change the type if either the existing symbol or the


More information about the Binutils mailing list