This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR ld/12975: --gc-sections doesn't remove symbols hidden with version scripts
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 15 Sep 2011 09:37:50 +0930
- Subject: Re: PATCH: PR ld/12975: --gc-sections doesn't remove symbols hidden with version scripts
- References: <20110914213245.GA16875@intel.com>
On Wed, Sep 14, 2011 at 02:32:45PM -0700, H.J. Lu wrote:
> @@ -11907,14 +11909,24 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
> {
> struct bfd_link_info *info = (struct bfd_link_info *) inf;
>
> - if ((h->root.type == bfd_link_hash_defined
> - || h->root.type == bfd_link_hash_defweak)
> - && (h->ref_dynamic
> - || (!info->executable
> - && h->def_regular
> - && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
> - && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN)))
> - h->root.u.def.section->flags |= SEC_KEEP;
> + if (h->root.type == bfd_link_hash_defined
> + || h->root.type == bfd_link_hash_defweak)
> + {
> + if (h->ref_dynamic)
> + h->root.u.def.section->flags |= SEC_KEEP;
> + else if (!info->executable
> + && h->def_regular
> + && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
> + && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN)
> + {
> + bfd_boolean hide;
> + if (info->version_info == NULL
> + || (bfd_find_version_for_sym (info->version_info,
> + h->root.root.string, &hide)
> + && !hide))
Is this correct? Seems to me this should be
if (info->version_info == NULL
|| !bfd_find_version_for_sym (info->version_info,
h->root.root.string, &hide)
|| !hide)
> + h->root.u.def.section->flags |= SEC_KEEP;
> + }
> + }
>
> return TRUE;
> }
--
Alan Modra
Australia Development Lab, IBM