PATCH: PR ld/12975: --gc-sections doesn't remove symbols hidden with version scripts

H.J. Lu hjl.tools@gmail.com
Thu Sep 15 00:30:00 GMT 2011


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?

-- 
H.J.



More information about the Binutils mailing list