diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-08-22 08:31:53 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-08-22 08:32:02 -0700 |
commit | 3f2e9699234ca31d083bc93ea6e03903f10baeaf (patch) | |
tree | bfe2e473c96a1b7c9cc4e3f9ea8bb90d2d946521 /bfd | |
parent | d19c3068ab17598662fe562e96bc1943b2b49736 (diff) | |
download | gdb-3f2e9699234ca31d083bc93ea6e03903f10baeaf.zip gdb-3f2e9699234ca31d083bc93ea6e03903f10baeaf.tar.gz gdb-3f2e9699234ca31d083bc93ea6e03903f10baeaf.tar.bz2 |
elf: Keep only one '@' for undefined versioned symbols
The symbol string table in the .symtab section is optional and cosmetic.
Keep only one '@' for undefined versioned symbols, which are defined in
shared objects, in the symbol string table. Update "nm -D" to display
only one '@' for undefined versioned symbols.
bfd/
PR ld/26382
* elflink.c (elf_link_output_symstrtab): Keep only one '@' for
versioned symbols, which are defined in shared objects, in
symbol string table.
binutils/
PR ld/26382
* nm.c (print_symname): Display only one '@' for undefined
versioned symbols.
* doc/binutils.texi: Update nm version information.
ld/
PR ld/26382
* testsuite/ld-elf/pr26302.nd: Updated.
* testsuite/ld-elf/pr26302.rd: New file.
* testsuite/ld-elf/shared.exp: Add a test for readelf -sW.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elflink.c | 22 |
2 files changed, 28 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d785337..b3c1c6a7 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2020-08-22 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/26382 + * elflink.c (elf_link_output_symstrtab): Keep only one '@' for + versioned symbols, which are defined in shared objects, in + symbol string table. + 2020-08-21 Nick Clifton <nickc@redhat.com> * elfnn-aarch64.c (_bfd_aarch64_erratum_835769_scan): Only sort diff --git a/bfd/elflink.c b/bfd/elflink.c index 0a7f5bb..17a4232 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -9642,9 +9642,29 @@ elf_link_output_symstrtab (struct elf_final_link_info *flinfo, { /* Call _bfd_elf_strtab_offset after _bfd_elf_strtab_finalize to get the final offset for st_name. */ + char *versioned_name = (char *) name; + if (h != NULL && h->versioned == versioned && h->def_dynamic) + { + /* Keep only one '@' for versioned symbols defined in shared + objects. */ + char *version = strrchr (name, ELF_VER_CHR); + char *base_end = strchr (name, ELF_VER_CHR); + if (version != base_end) + { + size_t base_len; + size_t len = strlen (name); + versioned_name = bfd_alloc (flinfo->output_bfd, len); + if (versioned_name == NULL) + return 0; + base_len = base_end - name; + memcpy (versioned_name, name, base_len); + memcpy (versioned_name + base_len, version, + len - base_len); + } + } elfsym->st_name = (unsigned long) _bfd_elf_strtab_add (flinfo->symstrtab, - name, FALSE); + versioned_name, FALSE); if (elfsym->st_name == (unsigned long) -1) return 0; } |