elflink.h -Bsymbolic change

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Sun Apr 8 14:06:00 GMT 2001


> Date: Tue, 3 Apr 2001 14:48:46 +1000 (EST)
> From: Alan Modra <alan@linuxcare.com.au>

> Anyone (cris, ia64, mips maintainers) see a problem with this?  AFAICT,
> this patch may actually benefit these ports.

> --- elflink.h.orig	Fri Mar  9 14:43:28 2001
> +++ elflink.h	Tue Apr  3 13:51:42 2001
> @@ -3518,24 +3518,25 @@ elf_fix_symbol_flags (h, eif)

Actually, this does the wrong thing for STV_PROTECTED.  The
patch causes symbol hiding, not just -- as it did before --
losing the PLT in a way which is wrong targets not using the
default bed->elf_backend_hide_symbol.  You must not hide
STV_PROTECTED symbols.  See the discussion nearby
<URL: http://sources.redhat.com/ml/binutils/2001-02/msg00081.html >).

With that patch, don't you see this failure in recent glibc (for
me, -D 2001-04-08 14:00 CET)?
IIUC it will happen for all archs.

 /glibcbuild/elf/vismain.o: In function `do_test':
 /glibc-fsf-cvs/elf/vismain.c:87: undefined reference to `protinmod'
 /glibc-fsf-cvs/elf/vismain.c:117: undefined reference to `protitcpt'

I see it in a (to-be-submitted) CRIS glibc port unless I revert
that patch or apply the following patch.  The following patch
changes hiding to be done the same way as in other
visibility-testing code in e.g. elf_link_add_object_symbols, so
I guess it's right.  What do the ELF experts say?

Note that I have only tested this by cross-compilation;
i.e. that the glibc test-case now links again.

If other visibilities *do* allow eliminating the PLT, then we
need some separate bed->elf_lose_symbol_plt_entry; hiding the
symbol is not applicable.

Ok to commit?

2001-04-08  Hans-Peter Nilsson  <hp@axis.com>

	* elflink.h (elf_fix_symbol_flags): For non-default visibilities,
	only hide symbols marked STV_INTERNAL or STV_HIDDEN.

Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.83
diff -p -c -r1.83 elflink.h
*** elflink.h	2001/04/04 00:31:37	1.83
--- elflink.h	2001/04/08 20:51:14
*************** elf_fix_symbol_flags (h, eif)
*** 3515,3526 ****
    /* If -Bsymbolic was used (which means to bind references to global
       symbols to the definition within the shared object), and this
       symbol was defined in a regular object, then it actually doesn't
!      need a PLT entry.  Likewise, if the symbol has any kind of
!      visibility (internal, hidden, or protected), it doesn't need a
!      PLT.  */
    if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
        && eif->info->shared
!       && (eif->info->symbolic || ELF_ST_VISIBILITY (h->other))
        && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
      {
        struct elf_backend_data *bed;
--- 3515,3530 ----
    /* If -Bsymbolic was used (which means to bind references to global
       symbols to the definition within the shared object), and this
       symbol was defined in a regular object, then it actually doesn't
!      need a PLT entry, and we can accomplish that by forcing it local.
!      Likewise, if the symbol has hidden or internal visibility.
!      FIXME: It might be that we also do not need a PLT for other
!      non-hidden visibilities, but we would have to tell that to the
!      backend specifically; we can't just clear PLT-related data here.  */
    if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
        && eif->info->shared
!       && (eif->info->symbolic
! 	  || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
! 	  || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
        && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
      {
        struct elf_backend_data *bed;

brgds, H-P



More information about the Binutils mailing list