This is the mail archive of the 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: [BFD][PR21703]Override the new defined symbol with the old normal symbol when --allow-multiple-definition is provided

On Tue, Jul 04, 2017 at 08:50:50PM +0100, Renlin Li wrote:
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -1569,6 +1569,15 @@ _bfd_elf_merge_symbol (bfd *abfd,
>        *size_change_ok = TRUE;
>      }
> +  /* The old symbol definition is overriding the new one if the symbol is a
> +     normal symbol.  */
> +  if (olddef && !olddyn && !oldweak
> +      && newdef && info->allow_multiple_definition)
> +    {
> +      *override = TRUE;
> +      return TRUE;
> +    }
> +
>    /* If we are looking at a dynamic object, and we have found a
>       definition, we need to see if the symbol was already defined by
>       some other object.  If so, we want to use the existing

This doesn't look correct to me.  override is really meant to handle
cases involving dynamic symbols.  I think skip should be set instead.

It might be easier to get the condition correct, and better for
maintenance, if you write

  if (<multiple definition detected>)
      if (!info->allow_multiple_definition)
	into->callbacks->multiple_definition (info, h, abfd, sec, *pvalue);
      *skip = TRUE;
      return TRUE;

ie. handle multiple definitions completely in _bfd_elf_merge_symbol.
I haven't written in the condition because I'll probably get it wrong
without testing.  :)

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]