PATCH: PR ld/14272: Mark the plugin symbol undefined

H.J. Lu hjl.tools@gmail.com
Tue Feb 3 17:06:00 GMT 2015


On Thu, Jun 28, 2012 at 3:10 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> LTO may optimize out a plugin symbol, which is also referenced by a
> non-IR file.  When that happens, we should mark the plugin symbol
> undefined.  It isn't the problem since LTO already determined the
> symbols in the non-IR file aren't used.  OK to install?
>
> Thanks.
>
>
> H.J.
> ---
> 2012-06-28  H.J. Lu  <hongjiu.lu@intel.com>
>
>         PR ld/14272
>         * elflink.c (_bfd_elf_fix_symbol_flags): Mark the plugin symbol
>         undefined if it is referenced from a non-IR file.
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index 8fb2ae3..4a0f858 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -2451,6 +2451,18 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h,
>      }
>    else
>      {
> +      /* If a plugin symbol is referenced from a non-IR file, mark
> +        the symbol as undefined.  */
> +      if (h->root.non_ir_ref
> +         && (h->root.type == bfd_link_hash_defined
> +             || h->root.type == bfd_link_hash_defweak)
> +         && h->root.u.def.section->owner != NULL
> +         && (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0)
> +       {
> +         h->root.type = bfd_link_hash_undefined;
> +         h->root.u.undef.abfd = h->root.u.def.section->owner;
> +       }
> +
>        /* Unfortunately, NON_ELF is only correct if the symbol
>          was first seen in a non-ELF file.  Fortunately, if the symbol
>          was first seen in an ELF file, we're probably OK unless the

I have been using it for more than 2 years.  I am checking in
this patch to completely fix PR ld/12365.

-- 
H.J.
---
bfd/

PR ld/12365
PR ld/14272
* elflink.c (_bfd_elf_fix_symbol_flags): Mark the plugin symbol
undefined if it is referenced from a non-IR file.

ld/testsuite/

PR ld/12365
* ld-plugin/pr12365a.c: New file.
* ld-plugin/pr12365b.c: Likewise.
* ld-plugin/pr12365c.c: Likewise.

* ld-plugin/lto.exp (lto_link_tests): Prepare for the PR ld/12365
test.
Run the PR ld/12365 test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Mark-the-plugin-symbol-undefined.patch
Type: text/x-patch
Size: 8198 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20150203/f5a9984e/attachment.bin>


More information about the Binutils mailing list