aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-02-24 16:31:29 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-02-25 04:13:42 -0800
commitef77d6af7cade17c566e4d1ecff098b841972f17 (patch)
treea2035fdd6e1de63b82861cbbaba141008c849c19 /bfd
parente6e7b7c49f960641ce1a97b967ca800128b1bf55 (diff)
downloadgdb-ef77d6af7cade17c566e4d1ecff098b841972f17.zip
gdb-ef77d6af7cade17c566e4d1ecff098b841972f17.tar.gz
gdb-ef77d6af7cade17c566e4d1ecff098b841972f17.tar.bz2
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf64-x86-64.c84
2 files changed, 49 insertions, 41 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2a32a6f..c52a0bc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2016-02-24 H.J. Lu <hongjiu.lu@intel.com>
+ * 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 <hongjiu.lu@intel.com>
+
PR ld/19698
* elflink.c (bfd_elf_record_link_assignment): Set versioned if
symbol version is unknown.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 7debc1e..48d263e 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;
}