[PATCH] ld: Ignore the new weak definition if needed

Alan Modra amodra@gmail.com
Mon Jul 20 23:16:59 GMT 2020


On Mon, Jul 20, 2020 at 06:34:29AM -0700, H.J. Lu via Binutils wrote:
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -1269,6 +1269,18 @@ _bfd_elf_merge_symbol (bfd *abfd,
>  	    && h->root.type != bfd_link_hash_undefweak
>  	    && h->root.type != bfd_link_hash_common);
>  
> +  /* NB: Ignore the new weak definition if the old definition comes
> +     from the LTO IR object since plugin_notice will turn it into
> +     undefweak.  */
> +  if (olddef
> +      && oldbfd
> +      && (oldbfd->flags & BFD_PLUGIN) != 0
> +      && newweak)
> +    {
> +      *skip = TRUE;
> +      return TRUE;
> +    }
> +
>    /* NEWFUNC and OLDFUNC indicate whether the new or old symbol,
>       respectively, appear to be a function.  */
>  

How do you square this with later code in _bfd_elf_merge_symbol?
See PR12696.

  /* Skip weak definitions of symbols that are already defined.  */
  if (newdef && olddef && newweak)
    {
      /* Don't skip new non-IR weak syms.  */
      if (!(oldbfd != NULL
	    && (oldbfd->flags & BFD_PLUGIN) != 0
	    && (abfd->flags & BFD_PLUGIN) == 0))
	{
	  newdef = FALSE;
	  *skip = TRUE;
	}


-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list