PATCH: Re: An undefined typed symbol bug?

H. J. Lu hjl@lucon.org
Thu Aug 21 23:10:00 GMT 2003


On Thu, Aug 21, 2003 at 03:42:26PM -0700, H. J. Lu wrote:
> I got
> 
> # make
> cc    -c -o x.o x.c
> as   -o y.o y.s
> ld -r -o foo.o x.o y.o
> ld -r -o foo.o y.o x.o
> ld: Warning: type of symbol `foo' changed from 1 to 2 in x.o
> 
> y.o has an undefined typed symbol, foo. Depending on if the linker
> sees the definition first, ld may issue a warning. I'd like to get
> rid of the warning. Any comments?
> 

How about this patch?


H.J.
-------------- next part --------------
2003-08-21  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (_bfd_elf_merge_symbol): Allow type change if
	the old symbol is undefined and the new symbol is defined.

--- bfd/elflink.c.type	2003-08-07 09:04:31.000000000 -0700
+++ bfd/elflink.c	2003-08-21 16:06:03.000000000 -0700
@@ -962,12 +962,14 @@ _bfd_elf_merge_symbol (bfd *abfd,
   /* It's OK to change the type if either the existing symbol or the
      new symbol is weak unless it comes from a DT_NEEDED entry of
      a shared object, in which case, the DT_NEEDED entry may not be
-     required at the run time.  */
+     required at the run time. The type change is also OK if the
+     old symbol is undefined and the new symbol is defined.  */
 
   if ((! dt_needed && oldweakdef)
       || oldweakundef
       || newweakdef
-      || newweakundef)
+      || newweakundef
+      || (newdef && !olddef))
     *type_change_ok = TRUE;
 
   /* It's OK to change the size if either the existing symbol or the


More information about the Binutils mailing list