This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: [PATCH] Mark __start/__stop symbols as PROTECTED in shared object


On Mon, Aug 14, 2017 at 04:53:41PM -0700, H.J. Lu wrote:
> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
> index 92a8e02e59..83958e41e0 100644
> --- a/bfd/elf-bfd.h
> +++ b/bfd/elf-bfd.h
> @@ -2802,7 +2802,9 @@ extern asection _bfd_elf_large_com_section;
>     library, if any.  A unique symbol can never be bound locally.  */
>  #define SYMBOLIC_BIND(INFO, H) \
>      (!(H)->unique_global \
> -     && ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic)))
> +     && ((INFO)->symbolic \
> +	 || (H)->start_stop \
> +	 || ((INFO)->dynamic && !(H)->dynamic)))
>  
>  #ifdef __cplusplus
>  }

If you make the symbols protected visibility, then this shouldn't be
needed.  (Except possibly for x86 because you broke the utility of
protected symbols in shared libraries.)

> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index f9886dc645..a3d8edd4c5 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -14261,17 +14261,55 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
>  			   const char *symbol, asection *sec)
>  {
>    struct bfd_link_hash_entry *h;
> +  struct elf_link_hash_entry *eh;
>  
>    h = bfd_generic_define_start_stop (info, symbol, sec);
> -  if (h != NULL)
> +  eh = (struct elf_link_hash_entry *) h;
> +  if (eh != NULL)
>      {
> -      struct elf_link_hash_entry *eh = (struct elf_link_hash_entry *) h;
>        eh->start_stop = 1;
>        eh->u2.start_stop_section = sec;
> -      _bfd_elf_link_hash_hide_symbol (info, eh, TRUE);
> +    }
> +  else
> +    {
> +      /* Override definition from a shared object.  */
> +       h = bfd_link_hash_lookup (info->hash, symbol, FALSE, FALSE,
> +				 FALSE);
> +       eh = (struct elf_link_hash_entry *) h;
> +       if (eh != NULL && eh->def_dynamic)

This should be testing ref_regular and ref_dynamic.  Also, I'm
inclined to think it might be better to not call
bfd_generic_define_start_stop and instead implement everything here.

> diff --git a/ld/testsuite/ld-elf/pr21562a.d b/ld/testsuite/ld-elf/pr21562a.d

Did you run these tests against most ELF targets?

-- 
Alan Modra
Australia Development Lab, IBM


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