+2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
+
+ 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.
+
2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23199
#ifndef MY_bfd_define_common_symbol
#define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
#endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
#ifndef MY_bfd_define_start_stop
#define MY_bfd_define_start_stop bfd_generic_define_start_stop
#endif
#ifndef MY_bfd_define_common_symbol
#define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
#endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
#ifndef MY_bfd_define_start_stop
#define MY_bfd_define_start_stop bfd_generic_define_start_stop
#endif
NAME##_bfd_discard_group, \
NAME##_section_already_linked, \
NAME##_bfd_define_common_symbol, \
+ NAME##_bfd_link_hide_symbol, \
NAME##_bfd_define_start_stop
int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
struct bfd_link_hash_entry *);
+ /* Hide a symbol. */
+ void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+ struct bfd_link_hash_entry *);
+
/* Define a __start, __stop, .startof. or .sizeof. symbol. */
struct bfd_link_hash_entry *
(*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
#define bfd_define_common_symbol(output_bfd, info, h) \
BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
+void _bfd_generic_link_hide_symbol
+ (bfd *output_bfd, struct bfd_link_info *info,
+ struct bfd_link_hash_entry *h);
+
+#define bfd_link_hide_symbol(output_bfd, info, h) \
+ BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+
struct bfd_link_hash_entry *bfd_generic_define_start_stop
(struct bfd_link_info *info,
const char *symbol, asection *sec);
#define binary_bfd_discard_group bfd_generic_discard_group
#define binary_section_already_linked _bfd_generic_section_already_linked
#define binary_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define binary_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define binary_bfd_define_start_stop bfd_generic_define_start_stop
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms
#define _bfd_ecoff_section_already_linked \
_bfd_coff_section_already_linked
#define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
#define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
#define _bfd_ecoff_section_already_linked \
_bfd_coff_section_already_linked
#define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
#define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
#define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
#define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
#define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
+#define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define _bfd_xcoff_bfd_define_start_stop bfd_generic_define_start_stop
#define _bfd_xcoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
bfd_generic_discard_group,
_bfd_generic_section_already_linked,
_bfd_xcoff_define_common_symbol,
+ _bfd_generic_link_hide_symbol,
bfd_generic_define_start_stop,
/* Dynamic */
bfd_generic_discard_group,
_bfd_generic_section_already_linked,
_bfd_xcoff_define_common_symbol,
+ _bfd_generic_link_hide_symbol,
bfd_generic_define_start_stop,
/* Dynamic */
#define coff_bfd_define_common_symbol bfd_generic_define_common_symbol
#endif
+#ifndef coff_bfd_link_hide_symbol
+#define coff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
+
#ifndef coff_bfd_define_start_stop
#define coff_bfd_define_start_stop bfd_generic_define_start_stop
#endif
struct elf_link_hash_entry *);
extern void _bfd_elf_link_hash_hide_symbol
(struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
+extern void _bfd_elf_link_hide_symbol
+ (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
(struct bfd_link_info *, struct elf_link_hash_entry *);
extern bfd_boolean _bfd_elf_link_hash_table_init
|| 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))
}
}
+/* 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. */
#define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
#endif
+#ifndef bfd_elfNN_bfd_link_hide_symbol
+#define bfd_elfNN_bfd_link_hide_symbol _bfd_elf_link_hide_symbol
+#endif
+
#ifndef bfd_elfNN_bfd_lookup_section_flags
#define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags
#endif
return TRUE;
}
- /* Symbols created by HIDDEN and PROVIDE_HIDDEN assignments in linker
- script aren't forced local here yet. bfd_hide_sym_by_version
- can't be used to check if a versioned symbol is hidden. It has to
- be syncd with _bfd_elf_link_assign_sym_version to get the correct
- answer. */
- if (!h->root.ldscript_def && h->versioned == unversioned)
+ /* bfd_hide_sym_by_version can't be used to check if a versioned symbol
+ is hidden. It has to be syncd with _bfd_elf_link_assign_sym_version
+ to get the correct answer. */
+ if (h->versioned == unversioned)
eh->local_ref = 1;
return FALSE;
#define msdos_section_already_linked \
_bfd_generic_section_already_linked
#define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define msdos_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define msdos_bfd_define_start_stop bfd_generic_define_start_stop
#define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define ihex_bfd_discard_group bfd_generic_discard_group
#define ihex_section_already_linked _bfd_generic_section_already_linked
#define ihex_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ihex_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define ihex_bfd_define_start_stop bfd_generic_define_start_stop
#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+ _bfd_generic_link_hide_symbol
extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
(struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
#define _bfd_nolink_bfd_link_check_relocs \
extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+ _bfd_generic_link_hide_symbol
extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
(struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
#define _bfd_nolink_bfd_link_check_relocs \
return TRUE;
}
+/*
+FUNCTION
+ _bfd_generic_link_hide_symbol
+
+SYNOPSIS
+ void _bfd_generic_link_hide_symbol
+ (bfd *output_bfd, struct bfd_link_info *info,
+ struct bfd_link_hash_entry *h);
+
+DESCRIPTION
+ Hide symbol @var{h}.
+ This is an internal function. It should not be called from
+ outside the BFD library.
+
+.#define bfd_link_hide_symbol(output_bfd, info, h) \
+. BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+.
+*/
+
+void
+_bfd_generic_link_hide_symbol (bfd *output_bfd ATTRIBUTE_UNUSED,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+}
+
/*
FUNCTION
bfd_generic_define_start_stop
#define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
#define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked
#define bfd_mach_o_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define bfd_mach_o_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define bfd_mach_o_bfd_define_start_stop bfd_generic_define_start_stop
#define bfd_mach_o_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
#define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p
#define mmo_section_already_linked \
_bfd_generic_section_already_linked
#define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define mmo_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define mmo_bfd_define_start_stop bfd_generic_define_start_stop
/* We want to copy time of creation, otherwise we'd use
#define bfd_pef_bfd_discard_group bfd_generic_discard_group
#define bfd_pef_section_already_linked _bfd_generic_section_already_linked
#define bfd_pef_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define bfd_pef_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define bfd_pef_bfd_define_start_stop bfd_generic_define_start_stop
#define bfd_pef_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define bfd_pef_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define bfd_plugin_bfd_discard_group bfd_generic_discard_group
#define bfd_plugin_section_already_linked _bfd_generic_section_already_linked
#define bfd_plugin_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define bfd_plugin_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define bfd_plugin_bfd_define_start_stop bfd_generic_define_start_stop
#define bfd_plugin_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type
#define bfd_plugin_bfd_link_check_relocs _bfd_generic_link_check_relocs
#define ppcboot_section_already_linked \
_bfd_generic_section_already_linked
#define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ppcboot_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define ppcboot_bfd_define_start_stop bfd_generic_define_start_stop
#define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define som_bfd_discard_group bfd_generic_discard_group
#define som_section_already_linked _bfd_generic_section_already_linked
#define som_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define som_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define som_bfd_define_start_stop bfd_generic_define_start_stop
#define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define srec_bfd_discard_group bfd_generic_discard_group
#define srec_section_already_linked _bfd_generic_section_already_linked
#define srec_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define srec_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define srec_bfd_define_start_stop bfd_generic_define_start_stop
#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
. NAME##_bfd_discard_group, \
. NAME##_section_already_linked, \
. NAME##_bfd_define_common_symbol, \
+. NAME##_bfd_link_hide_symbol, \
. NAME##_bfd_define_start_stop
.
. int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
. bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
. struct bfd_link_hash_entry *);
.
+. {* Hide a symbol. *}
+. void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+. struct bfd_link_hash_entry *);
+.
. {* Define a __start, __stop, .startof. or .sizeof. symbol. *}
. struct bfd_link_hash_entry *
. (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
#define tekhex_bfd_discard_group bfd_generic_discard_group
#define tekhex_section_already_linked _bfd_generic_section_already_linked
#define tekhex_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define tekhex_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define tekhex_bfd_define_start_stop bfd_generic_define_start_stop
#define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define vms_bfd_discard_group bfd_generic_discard_group
#define vms_section_already_linked _bfd_generic_section_already_linked
#define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define vms_bfd_define_start_stop bfd_generic_define_start_stop
#define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
_bfd_generic_section_already_linked
#define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
#define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
#define alpha_vms_bfd_copy_link_hash_symbol_type \
#define bfd_sym_bfd_discard_group bfd_generic_discard_group
#define bfd_sym_section_already_linked _bfd_generic_section_already_linked
#define bfd_sym_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define bfd_sym_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define bfd_sym_bfd_define_start_stop bfd_generic_define_start_stop
#define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
+2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
+
+ 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.
+
2018-05-18 H.J. Lu <hongjiu.lu@intel.com>
PR ld/23194
h->u.def.section = expld.result.section;
h->linker_def = ! tree->assign.type.lineno;
h->ldscript_def = 1;
+ if (tree->assign.hidden)
+ bfd_link_hide_symbol (link_info.output_bfd,
+ &link_info, h);
/* Copy the symbol type if this is an expression only
referencing a single symbol. (If the expression
+++ /dev/null
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#pass
+++ /dev/null
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#pass
"$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
"" \
[list provide-hidden-3.s] \
- [list "readelf -s provide-hidden-dynsec.nd"] \
+ [list \
+ [list readelf -s provide-hidden-sec.nd] \
+ [list readelf -s provide-hidden-dyn.nd]] \
"provide-hidden-4"] \
[list \
"$testname 5" \
"$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
"" \
[list provide-hidden-3.s] \
- [list "readelf -s provide-hidden-dynabs.nd"] \
+ [list \
+ [list readelf -s provide-hidden-abs.nd] \
+ [list readelf -s provide-hidden-dyn.nd]] \
"provide-hidden-10"] \
[list \
"$testname 11" \
#ld: -shared -melf_i386 -T pr23189.t
#readelf: -r --wide
-Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
- Offset Info Type Sym. Value Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE +
+There are no relocations in this file.
#ld: -shared -melf_x86_64 -T pr23189.t
#readelf: -r --wide
-Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
- Offset Info Type Symbol's Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+There are no relocations in this file.