PATCH: PR ld/12975: --gc-sections doesn't remove symbols hidden with version scripts
H.J. Lu
hjl.tools@gmail.com
Thu Sep 15 21:29:00 GMT 2011
On Wed, Sep 14, 2011 at 5:30 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Sep 14, 2011 at 5:07 PM, Alan Modra <amodra@gmail.com> wrote:
>> 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;
>>> }
>>
>
> I copied it from _bfd_elf_export_symbol. Should it be also
> changed?
>
I added bfd_hide_sym_by_version and also use it to check if
a LTO symbol is hidden by version script. OK to install?
Thanks.
--
H.J.
---
bfd/
2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12975
* bfd-in.h (bfd_elf_size_dynamic_sections): Remove pointer
to struct bfd_elf_version_tree.
* bfd-in2.h: Regenerated.
* elflink.c (elf_info_failed): Remove verdefs.
(_bfd_elf_export_symbol): Updated.
_bfd_elf_link_assign_sym_version): Likewise.
(bfd_elf_size_dynamic_sections): Remove pointer to struct
bfd_elf_version_tree. Updated.
(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is hidden
by linker script.
* linker.c (bfd_hide_sym_by_version): New.
include/
2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12975
* bfdlink.h (bfd_link_info): Add version_info.
ld/
2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12975
* ldlang.c (lang_elf_version_info): Removed.
(lang_register_vers_node): Replace lang_elf_version_info with
link_info.version_info.
(lang_add_vers_depend): Likewise.
* pe-dll.c (process_def_file_and_drectve): Likewise.
* emultempl/solaris2.em (elf_solaris2_before_allocation): Likewise.
* ldlang.h (lang_elf_version_info): Removed.
* plugin.c (is_visible_from_outside): Check if symbol is hidden
by version script.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
Remove lang_elf_version_info.
ld/testsuite/
2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12975
* ld-elf/pr12975.d: New.
* ld-elf/pr12975.s: Likewise.
* ld-elf/pr12975.t: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-pr12975-2.patch
Type: text/x-diff
Size: 16663 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20110915/7989f384/attachment.bin>
More information about the Binutils
mailing list