+2015-04-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/pr17709
+ * elf32-i386.c (elf_i386_relocate_section): Also check R_386_GOTOFF
+ against protected data symbol when building shared library.
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Also check
+ R_X86_64_GOTOFF64 against protected data symbol when building
+ shared library.
+
2015-04-10 H.J. Lu <hongjiu.lu@intel.com>
PR ld/pr15228
/* Relocation is relative to the start of the global offset
table. */
- /* Check to make sure it isn't a protected function symbol
- for shared library since it may not be local when used
- as function address. We also need to make sure that a
- symbol is defined locally. */
+ /* Check to make sure it isn't a protected function or data
+ symbol for shared library since it may not be local when
+ used as function address or with copy relocation. We also
+ need to make sure that a symbol is defined locally. */
if (info->shared && h)
{
if (!h->def_regular)
}
else if (!info->executable
&& !SYMBOLIC_BIND (info, h)
- && h->type == STT_FUNC
+ && (h->type == STT_FUNC
+ || h->type == STT_OBJECT)
&& ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
{
(*_bfd_error_handler)
- (_("%B: relocation R_386_GOTOFF against protected function `%s' can not be used when making a shared object"),
- input_bfd, h->root.root.string);
+ (_("%B: relocation R_386_GOTOFF against protected %s `%s' can not be used when making a shared object"),
+ input_bfd,
+ h->type == STT_FUNC ? "function" : "data",
+ h->root.root.string);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* Relocation is relative to the start of the global offset
table. */
- /* Check to make sure it isn't a protected function symbol
- for shared library since it may not be local when used
- as function address. */
+ /* Check to make sure it isn't a protected function or data
+ symbol for shared library since it may not be local when
+ used as function address or with copy relocation. */
if (!info->executable
&& h
&& !SYMBOLIC_BIND (info, h)
&& h->def_regular
- && h->type == STT_FUNC
+ && (h->type == STT_FUNC
+ || h->type == STT_OBJECT)
&& ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
{
(*_bfd_error_handler)
- (_("%B: relocation R_X86_64_GOTOFF64 against protected function `%s' can not be used when making a shared object"),
- input_bfd, h->root.root.string);
+ (_("%B: relocation R_X86_64_GOTOFF64 against protected %s `%s' can not be used when making a shared object"),
+ input_bfd,
+ h->type == STT_FUNC ? "function" : "data",
+ h->root.root.string);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
+2015-04-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/pr17709
+ * ld-i386/protected6.d: New file.
+ * ld-i386/protected6.s: Likewise.
+ * ld-x86-64/protected6.d: Likewise.
+ * ld-x86-64/protected6.s: Likewise.
+ * ld-x86-64/protected7.d: Likewise.
+ * ld-x86-64/protected7.s: Likewise.
+ * ld-x86-64/protected7a.d: Likewise.
+ * ld-x86-64/protected7b.d: Likewise.
+
2015-04-10 H.J. Lu <hongjiu.lu@intel.com>
PR ld/pr15228
run_dump_test "protected3"
run_dump_test "protected4"
run_dump_test "protected5"
+run_dump_test "protected6"
run_dump_test "tlspie1"
run_dump_test "tlspie2"
run_dump_test "nogot1"
--- /dev/null
+#as: --32
+#ld: -shared -melf_i386
+#error: .*relocation R_386_GOTOFF against protected data `foo' can not be used when making a shared object
--- /dev/null
+ .data
+ .protected foo
+ .globl foo
+ .align 4
+ .type foo, @object
+ .size foo, 4
+foo:
+ .long 1
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ movl foo@GOTOFF(%ecx), %eax
+ .size bar, .-bar
--- /dev/null
+#as: --64
+#ld: -shared -melf_x86_64
+#error: .*relocation R_X86_64_GOTOFF64 against protected data `foo' can not be used when making a shared object
--- /dev/null
+ .protected foo
+.globl foo
+ .data
+ .align 4
+ .type foo, @object
+ .size foo, 4
+foo:
+ .long 1
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ movabsq $foo@GOTOFF, %rax
+ .size bar, .-bar
--- /dev/null
+ .text
+.globl foo
+ .protected foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+.globl bar
+ .type bar, @function
+bar:
+ movabsq $foo@GOTOFF, %rax
+ .size bar, .-bar
--- /dev/null
+#source: protected7.s
+#as: --64
+#ld: -shared -melf_x86_64
+#error: .*relocation R_X86_64_GOTOFF64 against protected function `foo' can not be used when making a shared object
--- /dev/null
+#source: protected7.s
+#as: --64
+#ld: -shared -Bsymbolic -melf_x86_64
+#readelf: -r
+
+There are no relocations in this file.
run_dump_test "protected3-l1om"
run_dump_test "protected4"
run_dump_test "protected5"
+run_dump_test "protected6"
+run_dump_test "protected7a"
+run_dump_test "protected7b"
run_dump_test "tlsle1"
run_dump_test "tlspie1"
run_dump_test "unique1"