aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf32-i386.c17
-rw-r--r--bfd/elf64-x86-64.c15
3 files changed, 28 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index dd30698..ea35435 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
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
PR ld/pr17709
* elf-bfd.h (elf_backend_data): Add extern_protected_data.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 52f4d33..af16da3 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -3714,10 +3714,10 @@ elf_i386_relocate_section (bfd *output_bfd,
/* 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)
@@ -3748,12 +3748,15 @@ elf_i386_relocate_section (bfd *output_bfd,
}
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;
}
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index ab72306..2b37c27 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -3955,19 +3955,22 @@ elf_x86_64_relocate_section (bfd *output_bfd,
/* 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;
}