aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-09-12 05:37:30 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-09-12 05:37:43 -0700
commit496afd17055aeb7d8f45e01715c475664f2b73bd (patch)
tree221e0db337f288cbced1e5e4189463c23733a1a1 /include
parente71774ed24cc6890285b174cb95caf79a7622466 (diff)
downloadgdb-496afd17055aeb7d8f45e01715c475664f2b73bd.zip
gdb-496afd17055aeb7d8f45e01715c475664f2b73bd.tar.gz
gdb-496afd17055aeb7d8f45e01715c475664f2b73bd.tar.bz2
elf: Add -z unique-symbol to avoid duplicated local symbol names
The symbol string table in the .symtab section is optional and cosmetic. The contents of the .symtab section have no impact on run-time execution. The symbol names in the symbol string table help distinguish addresses at different locations. Add a linker option, -z unique-symbol, to avoid duplicated local symbol names in the symbol string table. This feature was well received by the livepatch maintainers. It not only solves the duplicated local symbol name problem, but also would allow livepatch to more precisely locate duplicate symbols in general for patching. bfd/ PR ld/26391 * elflink.c (elf_final_link_info): Add local_hash_table. (local_hash_entry): New. (local_hash_newfunc): Likewise. (elf_link_output_symstrtab): Append ".COUNT" to duplicated local symbols. (bfd_elf_final_link): Initialize and free local_hash_table for "-z unique-symbol". include/ PR ld/26391 * bfdlink.h (bfd_link_info): Add unique_symbol. ld/ PR ld/26391 * NEWS: Mention "-z unique-symbol". * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Handle "-z unique-symbol" and "-z nounique-symbol". * ld.texi: Document "-z unique-symbol" and "-z nounique-symbol". * lexsup.c (elf_static_list_options): Add "-z unique-symbol" and "-z nounique-symbol". * testsuite/ld-elf/elf.exp: Add PR ld/26391 tests. * testsuite/ld-elf/pr26391.nd: New file. * testsuite/ld-elf/pr26391.out: Likewise. * testsuite/ld-elf/pr26391a.c: Likewise. * testsuite/ld-elf/pr26391b.c: Likewise. * testsuite/ld-elf/pr26391c.c: Likewise. * testsuite/ld-elf/pr26391d.c: Likewise.
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog5
-rw-r--r--include/bfdlink.h3
2 files changed, 8 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index c8a90cf..38baf59 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/26391
+ * bfdlink.h (bfd_link_info): Add unique_symbol.
+
2020-09-11 Felix Willgerodt <felix.willgerodt@intel.com>
Sync with GCC
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 3badfbdb..55020e3 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -523,6 +523,9 @@ struct bfd_link_info
the linker. */
unsigned int non_contiguous_regions_warnings : 1;
+ /* TRUE if all symbol names should be unique. */
+ unsigned int unique_symbol : 1;
+
/* Char that may appear as the first char of a symbol, but should be
skipped (like symbol_leading_char) when looking up symbols in
wrap_hash. Used by PowerPC Linux for 'dot' symbols. */