This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Re: An undefined typed symbol bug?
On Thu, Aug 21, 2003 at 08:47:01PM -0700, H. J. Lu wrote:
> On Fri, Aug 22, 2003 at 11:35:11AM +0930, Alan Modra wrote:
> > Without knowing the background, I'd say we should keep the warning,
> > and possibly fix the case where we currently don't warn. The testcase
> > explicitly sets the type of the undefined symbol to @object. I think
> > a warning is in order when satisfying the reference with a @function
> > symbol.
>
> Not all compilers generate undefined symbols with types. Gcc doesn't.
> The warning doesn't provide anything useful. In C, you use the same
> prototype for definition and reference to make sure they are consistent.
> In assembly, anything goes and linker shouldn't bother.
>
> >
> > I'm thinking of ABIs like powerpc64-linux with function descriptors
> > as a reason for wanting to distinguish between the descriptor and its
> > code.
>
> The code is written on purpose. The goal is to get the address of the
> function body, not its function descriptor.
>
Here is an update. Common symbol shouldn't be treated as undefined in
this case.
H.J.
----
2003-08-22 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-22 22:30:18.000000000 -0700
@@ -962,12 +962,16 @@ _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
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)))
*type_change_ok = TRUE;
/* It's OK to change the size if either the existing symbol or the