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]

Re: A patch to only warn undefined symbol in DSO to be built


On Wed, 7 Feb 2001, H . J . Lu wrote:

> > +++ elflink.h	2001/02/07 07:58:30
> > @@ -5092,9 +5092,10 @@ elf_link_output_extsym (h, data)
> >       warnings for them.  */
> >    if (! finfo->info->relocateable
> >        && ! finfo->info->allow_shlib_undefined
> > -      && ! (finfo->info->shared
> > -	    && !finfo->info->no_undefined)
> >        && h->root.type == bfd_link_hash_undefined
> > +      && (! finfo->info->shared
> > +	  || ! finfo->info->no_undefined
> > +	  || (h->root.u.undef.abfd->flags & DYNAMIC) == 0)
> >        && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
> >        && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
> >      {
> > 
> > It does the same thing in a slightly different way, but also checks for
> 
> Are you sure it works? I added

At least as sure as you are that yours works. :-)  I'm quite happy that we
both decided the same area of code needed patching, BTW.  As regards
testing, I built the following as a shared lib with --no-undefined.
====
#include <stdio.h>

extern int missing_sym;

int m (void)
{
  printf ("Hello\n");
  return missing_sym;
}
===

> finfo->output_bfd == h->root.u.undef.abfd

(flags & DYNAMIC) does the same thing, but in a clearer way IMO.

> to check if the undefined symbol is in the DSO to be built.
> 
> > bfd_link_hash_undefined before accessing h_.root.u.undef
> > 
> 
> That is not bad.

I consider it bad progamming practice to access fields of a union
that aren't valid, especialy where you might read memory that's never been
written (not in this case), or where pointers are involved.  Some
architectures have weird pointers, and there may be machines that trap
when invalid bit patterns are loaded into pointer registers.

Alan Modra
-- 
Linuxcare.  Support for the Revolution.



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