aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-10-24 18:08:13 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-10-24 18:08:24 -0700
commit0a640d719684f25bdb88ae60148c6978e6131701 (patch)
tree847a75473aa7a2d0009da97e8a8665d2261b44e2 /bfd/elflink.c
parent0e139b87870258ce666826efd14fafd543c778d0 (diff)
downloadgdb-0a640d719684f25bdb88ae60148c6978e6131701.zip
gdb-0a640d719684f25bdb88ae60148c6978e6131701.tar.gz
gdb-0a640d719684f25bdb88ae60148c6978e6131701.tar.bz2
ELF: Hide symbols defined in discarded input sections
When assigning symbol version, we should hide debug symbols defined in discarded sections from IR objects so that they can be removed later. bfd/ PR ld/23818 * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols defined in discarded input sections. ld/ PR ld/23818 * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test. * testsuite/ld-plugin/pr23818.d: New file. * testsuite/ld-plugin/pr23818.t: Likewise. * testsuite/ld-plugin/pr23818a.c: Likewise. * testsuite/ld-plugin/pr23818b.c: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 87440db..4eca389 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2359,13 +2359,21 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data)
return FALSE;
}
+ bed = get_elf_backend_data (info->output_bfd);
+
/* We only need version numbers for symbols defined in regular
objects. */
if (!h->def_regular)
- return TRUE;
+ {
+ /* Hide symbols defined in discarded input sections. */
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && discarded_section (h->root.u.def.section))
+ (*bed->elf_backend_hide_symbol) (info, h, TRUE);
+ return TRUE;
+ }
hide = FALSE;
- bed = get_elf_backend_data (info->output_bfd);
p = strchr (h->root.root.string, ELF_VER_CHR);
if (p != NULL && h->verinfo.vertree == NULL)
{