summaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2008-03-16 22:26:23 +0000
committerH.J. Lu <hjl@lucon.org>2008-03-16 22:26:23 +0000
commitffd6230972978c5154574ec7ae6676ecaef00126 (patch)
treec79cdc8cb6b0639a6f94febb18a85ee5d2676573 /bfd/elf32-i386.c
parent5342976e58b39ab58a70d825e5ae16a05ede96cc (diff)
downloadbinutils-redhat-ffd6230972978c5154574ec7ae6676ecaef00126.tar.gz
bfd/
2008-03-16 H.J. Lu <hongjiu.lu@intel.com> PR ld/5789 PR ld/5943 * elf32-i386.c (elf_i386_relocate_section): Issue an error for R_386_GOTOFF relocaton against undefined hidden/internal symbols when building a shared object. * elf64-x86-64.c (elf64_x86_64_relocate_section): Issue an error for R_X86_64_PC8/R_X86_64_PC16/R_X86_64_PC32 relocaton against undefined hidden/internal symbols when building a shared object. (elf64_x86_64_finish_dynamic_symbol): Return FALSE when symbol is referenced locally, but isn't defined in a regular file. ld/testsuite/ 2008-03-16 H.J. Lu <hongjiu.lu@intel.com> PR ld/5789 PR ld/5943 * ld-i386/hidden1.d: New. * ld-i386/hidden1.s: Likewise. * ld-i386/hidden2.d: Likewise. * ld-i386/hidden2.s: Likewise. * ld-i386/hidden3.d: Likewise. * ld-i386/hidden4.s: Likewise. * ld-i386/protected1.d: Likewise. * ld-i386/protected1.s: Likewise. * ld-i386/protected2.d: Likewise. * ld-i386/protected2.s: Likewise. * ld-i386/protected3.d: Likewise. * ld-i386/protected3.s: Likewise. * ld-x86-64/hidden1.d: Likewise. * ld-x86-64/hidden1.s: Likewise. * ld-x86-64/hidden2.d: Likewise. * ld-x86-64/hidden2.s: Likewise. * ld-x86-64/hidden3.d: Likewise. * ld-x86-64/hidden3.s: Likewise. * ld-x86-64/protected1.d: Likewise. * ld-x86-64/protected1.s: Likewise. * ld-x86-64/protected2.d: Likewise. * ld-x86-64/protected2.s: Likewise. * ld-x86-64/protected3.d: Likewise. * ld-x86-64/protected3.s: Likewise. * ld-i386/i386.exp: Run hidden1, hidden2, hidden3, protected1, protected2 and protected3. * ld-x86-64/x86-64.exp: Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 432e7d3c45..c10dbb3409 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2753,19 +2753,46 @@ elf_i386_relocate_section (bfd *output_bfd,
/* 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. */
- if (info->shared
- && !info->executable
- && h
- && h->def_regular
- && h->type == STT_FUNC
- && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
+ as function address. We also need to make sure that a
+ symbol is defined locally. */
+ if (info->shared && h)
{
- (*_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);
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
+ if (!h->def_regular)
+ {
+ const char *v;
+
+ switch (ELF_ST_VISIBILITY (h->other))
+ {
+ case STV_HIDDEN:
+ v = _("hidden symbol");
+ break;
+ case STV_INTERNAL:
+ v = _("internal symbol");
+ break;
+ case STV_PROTECTED:
+ v = _("protected symbol");
+ break;
+ default:
+ v = _("symbol");
+ break;
+ }
+
+ (*_bfd_error_handler)
+ (_("%B: relocation R_386_GOTOFF against undefined %s `%s' can not be used when making a shared object"),
+ input_bfd, v, h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ else if (!info->executable
+ && h->type == STT_FUNC
+ && 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);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
}
/* Note that sgot is not involved in this