diff options
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elflink.c | 39 |
2 files changed, 25 insertions, 20 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c574570..e481c1b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2021-05-05 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/27825 + * elflink.c (elf_link_output_symstrtab): Always append ".COUNT" + to local symbols. + 2021-05-05 Alan Modra <amodra@gmail.com> * vms-lib.c (vms_traverse_index): Account for vms_kbn size when diff --git a/bfd/elflink.c b/bfd/elflink.c index cb38a02..0e1871a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -9830,6 +9830,9 @@ elf_link_output_symstrtab (void *finf, && ELF_ST_BIND (elfsym->st_info) == STB_LOCAL) { struct local_hash_entry *lh; + size_t count_len; + size_t base_len; + char buf[30]; switch (ELF_ST_TYPE (elfsym->st_info)) { case STT_FILE: @@ -9840,28 +9843,24 @@ elf_link_output_symstrtab (void *finf, (&flinfo->local_hash_table, name, true, false); if (lh == NULL) return 0; - if (lh->count) + /* Always append ".COUNT" to local symbols to avoid + potential conflicts with local symbol "XXX.COUNT". */ + sprintf (buf, "%lx", lh->count); + base_len = lh->size; + if (!base_len) { - /* Append ".COUNT" to duplicated local symbols. */ - size_t count_len; - size_t base_len = lh->size; - char buf[30]; - sprintf (buf, "%lx", lh->count); - if (!base_len) - { - base_len = strlen (name); - lh->size = base_len; - } - count_len = strlen (buf); - versioned_name = bfd_alloc (flinfo->output_bfd, - base_len + count_len + 2); - if (versioned_name == NULL) - return 0; - memcpy (versioned_name, name, base_len); - versioned_name[base_len] = '.'; - memcpy (versioned_name + base_len + 1, buf, - count_len + 1); + base_len = strlen (name); + lh->size = base_len; } + count_len = strlen (buf); + versioned_name = bfd_alloc (flinfo->output_bfd, + base_len + count_len + 2); + if (versioned_name == NULL) + return 0; + memcpy (versioned_name, name, base_len); + versioned_name[base_len] = '.'; + memcpy (versioned_name + base_len + 1, buf, + count_len + 1); lh->count++; break; } |