This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Confusing meaning of --no-undefined
On Tue, Feb 11, 2003 at 05:30:45PM +0000, Nick Clifton wrote:
> concerning the fact that:
>
> ld --share --no-undefined foo.o bar.so
>
> does not report an undefined symbol in bar.so.
I think there's general agreement that this is desirable default
behaviour. ie. --no-undefined should only report undefined references
in the shared lib being built, _not_ in other libraries linked
against.
> *** bfd/elflink.h 4 Feb 2003 12:49:57 -0000 1.204
> --- bfd/elflink.h 11 Feb 2003 17:09:10 -0000
> *************** elf_link_output_extsym (h, data)
> *** 6096,6103 ****
> referenced by regular files, because we will already have issued
> warnings for them. */
> if (! finfo->info->relocateable
> ! && ! finfo->info->allow_shlib_undefined
> ! && ! finfo->info->shared
> && h->root.type == bfd_link_hash_undefined
> && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
> && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
> --- 6097,6103 ----
> referenced by regular files, because we will already have issued
> warnings for them. */
> if (! finfo->info->relocateable
> ! && (! finfo->info->shared || ! finfo->info->allow_shlib_undefined)
> && h->root.type == bfd_link_hash_undefined
> && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
> && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
>
> and sure enough the error message in Jan's test was now correctly
> generated. When I ran the linker tests however, I discovered that
> this patch causes the ld-elfweak tests to fail:
Yeah, this code does look wrong, and I was the last to touch it. :-(
I think your patch makes sense, but you should also update the comment
and default allow_shlib_undefined to 1. The other thing is that I see
code like the following from elf32-i386.c:
else if (info->shared
&& (!info->symbolic || info->allow_shlib_undefined)
&& !info->no_undefined
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
else
report an error
This seems like another bogus test of allow_shlib_undefined. Or at
least it's an entirely different usage only affecting -Bsymbolic libs.
You could accomplish the same effect by not requesting --no-undefined.
ie. I think we want
else if (info->shared
&& !info->no_undefined
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
else
report an error
--
Alan Modra
IBM OzLabs - Linux Technology Centre