From: H.J. Lu Date: Thu, 25 Feb 2016 00:31:29 +0000 (-0800) Subject: Add elf_x86_64_need_pic X-Git-Tag: users/hjl/linux/release/2.26.51.0.1~1^2~5^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef77d6af7cade17c566e4d1ecff098b841972f17;p=thirdparty%2Fbinutils-gdb.git Add elf_x86_64_need_pic Add elf_x86_64_need_pic and replace x86_64_elf_howto_table[r_type].name with howto->name. * elf64-x86-64.c (elf_x86_64_need_pic): New function. (elf_x86_64_relocate_section): Use it. Replace x86_64_elf_howto_table[r_type] with howto. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2a32a6f0d91..c52a0bc7b71 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2016-02-24 H.J. Lu + + * elf64-x86-64.c (elf_x86_64_need_pic): New function. + (elf_x86_64_relocate_section): Use it. Replace + x86_64_elf_howto_table[r_type] with howto. + 2016-02-24 H.J. Lu PR ld/19698 diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 7debc1e6c1d..48d263e388c 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3861,6 +3861,42 @@ is_32bit_relative_branch (bfd_byte *contents, bfd_vma offset) && (contents [offset - 1] & 0xf0) == 0x80)); } +static bfd_boolean +elf_x86_64_need_pic (bfd *input_bfd, struct elf_link_hash_entry *h, + reloc_howto_type *howto) +{ + const char *fmt; + const char *v; + const char *pic = ""; + + 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"); + pic = _("; recompile with -fPIC"); + break; + } + + if (h->def_regular) + fmt = _("%B: relocation %s against %s `%s' can not be used when making a shared object%s"); + else + fmt = _("%B: relocation %s against undefined %s `%s' can not be used when making a shared object%s"); + + (*_bfd_error_handler) (fmt, input_bfd, howto->name, + v, h->root.root.string, pic); + bfd_set_error (bfd_error_bad_value); + return FALSE; +} + /* Relocate an x86_64 ELF section. */ static bfd_boolean @@ -4078,8 +4114,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, (*_bfd_error_handler) (_("%B: relocation %s against STT_GNU_IFUNC " "symbol `%s' isn't handled by %s"), input_bfd, - x86_64_elf_howto_table[r_type].name, - name, __FUNCTION__); + howto->name, name, __FUNCTION__); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -4103,8 +4138,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, (*_bfd_error_handler) (_("%B: relocation %s against STT_GNU_IFUNC " "symbol `%s' has non-zero addend: %d"), - input_bfd, x86_64_elf_howto_table[r_type].name, - name, rel->r_addend); + input_bfd, howto->name, name, rel->r_addend); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4536,39 +4570,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, } if (fail) - { - const char *fmt; - const char *v; - const char *pic = ""; - - 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"); - pic = _("; recompile with -fPIC"); - break; - } - - if (h->def_regular) - fmt = _("%B: relocation %s against %s `%s' can not be used when making a shared object%s"); - else - fmt = _("%B: relocation %s against undefined %s `%s' can not be used when making a shared object%s"); - - (*_bfd_error_handler) (fmt, input_bfd, - x86_64_elf_howto_table[r_type].name, - v, h->root.root.string, pic); - bfd_set_error (bfd_error_bad_value); - return FALSE; - } + return elf_x86_64_need_pic (input_bfd, h, howto); } /* Fall through. */ @@ -4681,16 +4683,16 @@ direct: "symbol `%s' at 0x%lx in section `%A' is " "out of range"), input_bfd, input_section, addend, - x86_64_elf_howto_table[r_type].name, - name, (unsigned long) rel->r_offset); + howto->name, name, + (unsigned long) rel->r_offset); else (*_bfd_error_handler) (_("%B: addend 0x%x in relocation %s against " "symbol `%s' at 0x%lx in section `%A' is " "out of range"), input_bfd, input_section, addend, - x86_64_elf_howto_table[r_type].name, - name, (unsigned long) rel->r_offset); + howto->name, name, + (unsigned long) rel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; }