+2015-04-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/pr17709
+ * elflink.c (_bfd_elf_adjust_dynamic_copy): Check
+ info->extern_protected_data when warning copy relocs against
+ protected symbols.
+ (_bfd_elf_symbol_refs_local_p): Check info->extern_protected_data
+ when checking protected non-function symbols.
+
2015-04-13 John Baldwin <jhb@FreeBSD.org>
* elf.c (elfcore_grok_note): Recognize NT_X86_XSTATE on
/* No error if extern_protected_data is true. */
if (h->protected_def
- && !get_elf_backend_data (dynbss->owner)->extern_protected_data)
+ && (!info->extern_protected_data
+ || (info->extern_protected_data < 0
+ && !get_elf_backend_data (dynbss->owner)->extern_protected_data)))
info->callbacks->einfo
(_("%P: copy reloc against protected `%T' is dangerous\n"),
h->root.root.string);
/* If extern_protected_data is false, STV_PROTECTED non-function
symbols are local. */
- if (!bed->extern_protected_data && !bed->is_function_type (h->type))
+ if ((!info->extern_protected_data
+ || (info->extern_protected_data < 0
+ && !bed->extern_protected_data))
+ && !bed->is_function_type (h->type))
return TRUE;
/* Function pointer equality tests may require that STV_PROTECTED
+2015-04-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/pr17709
+ * bfdlink.h (bfd_link_info): Add extern_protected_data.
+
2015-03-10 Matthew Wahab <matthew.wahab@arm.com>
PR ld/16572
relaxation returning true in *AGAIN. */
int relax_trip;
+ /* > 0 to treat protected data defined in the shared library as
+ reference external. 0 to treat it as internal. -1 to let
+ backend to decide. */
+ int extern_protected_data;
+
/* Non-zero if auto-import thunks for DATA items in pei386 DLLs
should be generated/linked against. Set to 1 if this feature
is explicitly requested by the user, -1 if enabled by default. */
+2015-04-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/pr17709
+ * ld.texinfo: Document "-z noextern-protected-data".
+ * ldmain.c (main): Initialize link_info.extern_protected_data
+ to -1.
+ * lexsup.c (elf_shlib_list_options): Add
+ "-z [no]extern-protected-data".
+ * emulparams/elf32_x86_64.sh: Source extern_protected_data.sh.
+ * emulparams/elf_i386.sh: Likewise.
+ * emulparams/elf_i386_be.sh: Likewise.
+ * emulparams/elf_i386_chaos.sh: Likewise.
+ * emulparams/elf_i386_ldso.sh: Likewise.
+ * emulparams/elf_i386_vxworks.sh: Likewise.
+ * emulparams/elf_k1om.sh: Likewise.
+ * emulparams/elf_l1om.sh: Likewise.
+ * emulparams/elf_x86_64.sh: Source extern_protected_data.sh.
+ (PARSE_AND_LIST_OPTIONS): Renamed to ...
+ (PARSE_AND_LIST_OPTIONS_BNDPLT): This.
+ (PARSE_AND_LIST_ARGS_CASE_Z): Renamed to ...
+ (PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT): This.
+ (PARSE_AND_LIST_OPTIONS): Append $PARSE_AND_LIST_OPTIONS_BNDPLT.
+ (PARSE_AND_LIST_ARGS_CASE_Z): Append
+ $PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT.
+ * emulparams/extern_protected_data.sh: New file.
+
2015-04-11 H.J. Lu <hongjiu.lu@intel.com>
* plugin.c (plugin_load_plugins): Removed an extra ';'.
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
ELFSIZE=32
OUTPUT_FORMAT="elf32-x86-64"
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
NO_RELA_RELOCS=yes
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
NO_RELA_RELOCS=yes
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf_chaos
OUTPUT_FORMAT="elf32-i386"
TEXT_START_ADDR=0x40000000
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
NO_RELA_RELOCS=yes
GENERATE_PIE_SCRIPT=yes
NO_SMALL_DATA=yes
. ${srcdir}/emulparams/vxworks.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-k1om"
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-l1om"
. ${srcdir}/emulparams/plt_unwind.sh
+. ${srcdir}/emulparams/extern_protected_data.sh
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-x86-64"
case "$EMULATION_NAME" in
*64*)
LIBPATH_SUFFIX=64
- PARSE_AND_LIST_OPTIONS='
+ PARSE_AND_LIST_OPTIONS_BNDPLT='
fprintf (file, _("\
-z bndplt Always generate BND prefix in PLT entries\n"));
'
- PARSE_AND_LIST_ARGS_CASE_Z='
+ PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT='
else if (strcmp (optarg, "bndplt") == 0)
link_info.bndplt = TRUE;
'
+ PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_BNDPLT"
+ PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT"
;;
esac
;;
--- /dev/null
+PARSE_AND_LIST_OPTIONS='
+ fprintf (file, _("\
+ -z noextern-protected-data Do not treat protected data symbol as external\n"));
+'
+
+PARSE_AND_LIST_ARGS_CASE_Z='
+ else if (strcmp (optarg, "noextern-protected-data") == 0)
+ link_info.extern_protected_data = FALSE;
+'
@item bndplt
Always generate BND prefix in PLT entries. Supported for Linux/x86_64.
+@item noextern-protected-data
+Don't treat protected data symbol as external when building shared
+library. This option overrides linker backend default. It can be used
+to workaround incorrect relocations against protected data symbols
+generated by compiler. Updates on protected data symbols by another
+module aren't visibile to the resulting shared library. Supported for
+i386 and x86-64.
+
@end table
Other keywords are ignored for Solaris compatibility.
link_info.init_function = "_init";
link_info.fini_function = "_fini";
link_info.relax_pass = 1;
+ link_info.extern_protected_data = -1;
link_info.pei386_auto_import = -1;
link_info.spare_dynamic_tags = 5;
link_info.path_separator = ':';
+2015-04-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/pr17709
+ * ld-i386/i386.exp: Run protected6b.
+ * ld-i386/protected6b.d: New file.
+ * ld-x86-64/protected6b.d: Likewise.
+ * ld-x86-64/x86-64.exp: Run protected6b.
+
2015-04-11 H.J. Lu <hongjiu.lu@intel.com>
* ld-i386/i386.exp: Run protected6a.
run_dump_test "protected4"
run_dump_test "protected5"
run_dump_test "protected6a"
+run_dump_test "protected6b"
run_dump_test "tlspie1"
run_dump_test "tlspie2"
run_dump_test "nogot1"
--- /dev/null
+#source: protected6.s
+#as: --32
+#ld: -shared -melf_i386 -z noextern-protected-data
+#readelf: -r
+
+There are no relocations in this file.
--- /dev/null
+#source: protected6.s
+#as: --64
+#ld: -shared -melf_x86_64 -z noextern-protected-data
+#readelf: -r
+
+There are no relocations in this file.
run_dump_test "protected4"
run_dump_test "protected5"
run_dump_test "protected6a"
+run_dump_test "protected6b"
run_dump_test "protected7a"
run_dump_test "protected7b"
run_dump_test "tlsle1"