aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-05-21 20:39:09 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-05-21 20:39:30 -0700
commit34a87bb07a4a3b2202fc25167a6b0f12575edc87 (patch)
tree1e5f01a95feb8860d22986e8131f367376e8a1dd /bfd/elflink.c
parentbae363f1146378207e1dffe5f23845644a1d0b7a (diff)
downloadbinutils-34a87bb07a4a3b2202fc25167a6b0f12575edc87.zip
binutils-34a87bb07a4a3b2202fc25167a6b0f12575edc87.tar.gz
binutils-34a87bb07a4a3b2202fc25167a6b0f12575edc87.tar.bz2
ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN
There should be no difference in output for symbols defined by HIDDEN or PROVIDE_HIDDEN assignments whether they are explicitly marked as hidden or not. This patch adds a new BFD function, bfd_link_hide_symbol, to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments. bfd PR ld/23201 * aout-target.h (MY_bfd_link_hide_symbol): New. * aout-tic30.c (MY_bfd_link_hide_symbol): Likewise. * binary.c (binary_bfd_link_hide_symbol): Likewise. * coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise. * coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise. * coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise. * coffcode.h (coff_bfd_link_hide_symbol): Likewise. * elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise. * elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise. * i386msdos.c (msdos_bfd_link_hide_symbol): Likewise. * ihex.c (ihex_bfd_link_hide_symbol): Likewise. * libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise. * linker.c (_bfd_generic_link_hide_symbol): Likewise. (bfd_link_hide_symbol): Likewise. * mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise. * mmo.c (mmo_bfd_link_hide_symbol): Likewise. * pef.c (bfd_pef_bfd_link_hide_symbol): Likewise. * plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise. * ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise. * som.c (som_bfd_link_hide_symbol): Likewise. * srec.c (srec_bfd_link_hide_symbol): Likewise. * tekhex.c (tekhex_bfd_link_hide_symbol): Likewise. * vms-alpha.c (vms_bfd_link_hide_symbol): Likewise. (alpha_vms_bfd_link_hide_symbol): Likewise. * xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise. * coff64-rs6000.c (rs6000_xcoff64_vec): Add _bfd_generic_link_hide_symbol. (rs6000_xcoff64_aix_vec): Likewise. * elflink.c (bfd_elf_record_link_assignment): Don't make forced local symbol dynamic. (_bfd_elf_link_hide_symbol): New function. * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't check root.ldscript_def. * targets.c (bfd_target): Add _bfd_link_hide_symbol. (BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. ld/ PR ld/23201 * ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide a symbol. * testsuite/ld-elf/provide-hidden-dynabs.nd: Removed. * testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise. * testsuite/ld-elf/provide-hidden.exp: Replace provide-hidden-dynsec.nd with provide-hidden-sec.nd and provide-hidden-dyn.nd. Replace provide-hidden-dynabs.nd with provide-hidden-abs.nd and provide-hidden-dyn.nd. * testsuite/ld-i386/pr23189.d: Expect no dynamic relocation. * testsuite/ld-x86-64/pr23189.d: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ce3765e..0383e4e 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -720,6 +720,7 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
|| h->ref_dynamic
|| bfd_link_dll (info)
|| elf_hash_table (info)->is_relocatable_executable)
+ && !h->forced_local
&& h->dynindx == -1)
{
if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -7429,6 +7430,26 @@ _bfd_elf_link_hash_hide_symbol (struct bfd_link_info *info,
}
}
+/* Hide a symbol. */
+
+void
+_bfd_elf_link_hide_symbol (bfd *output_bfd,
+ struct bfd_link_info *info,
+ struct bfd_link_hash_entry *h)
+{
+ if (is_elf_hash_table (info->hash))
+ {
+ const struct elf_backend_data *bed
+ = get_elf_backend_data (output_bfd);
+ struct elf_link_hash_entry *eh
+ = (struct elf_link_hash_entry *) h;
+ bed->elf_backend_hide_symbol (info, eh, TRUE);
+ eh->def_dynamic = 0;
+ eh->ref_dynamic = 0;
+ eh->dynamic_def = 0;
+ }
+}
+
/* Initialize an ELF linker hash table. *TABLE has been zeroed by our
caller. */