Display signed hex number in x32 addend overflow check

bfd/

	* elf64-x86-64.c (elf_x86_64_relocate_section): Display signed
	hex number in x32 addend overflow check.

gas/

	* config/tc-i386.c (tc_gen_reloc): Display signed hex number in
	x32 addend overflow check.

ld/testsuite/

	* ld-x86-64/ilp32-11.d: Updated.
This commit is contained in:
H.J. Lu
2012-05-10 20:46:34 +00:00
parent 95554aad6c
commit 6f2c9068ed
6 changed files with 43 additions and 13 deletions

@ -1,3 +1,8 @@
2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
* elf64-x86-64.c (elf_x86_64_relocate_section): Display signed
hex number in x32 addend overflow check.
2012-05-10 H.J. Lu <hongjiu.lu@intel.com> 2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
* elf64-x86-64.c (elf_x86_64_reloc_type_class): Handle * elf64-x86-64.c (elf_x86_64_reloc_type_class): Handle

@ -3686,17 +3686,26 @@ elf_x86_64_relocate_section (bfd *output_bfd,
!= (rel->r_addend & 0x80000000)) != (rel->r_addend & 0x80000000))
{ {
const char *name; const char *name;
long addend = rel->r_addend;
if (h && h->root.root.string) if (h && h->root.root.string)
name = h->root.root.string; name = h->root.root.string;
else else
name = bfd_elf_sym_name (input_bfd, symtab_hdr, name = bfd_elf_sym_name (input_bfd, symtab_hdr,
sym, NULL); sym, NULL);
if (addend < 0)
(*_bfd_error_handler) (*_bfd_error_handler)
(_("%B: addend %ld in relocation %s against " (_("%B: addend -0x%lx in relocation %s against "
"symbol `%s' at 0x%lx in section `%A' is " "symbol `%s' at 0x%lx in section `%A' is "
"out of range"), "out of range"),
input_bfd, input_section, input_bfd, input_section, addend,
(long) rel->r_addend, x86_64_elf_howto_table[r_type].name,
name, (unsigned long) rel->r_offset);
else
(*_bfd_error_handler)
(_("%B: addend 0x%lx 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, x86_64_elf_howto_table[r_type].name,
name, (unsigned long) rel->r_offset); name, (unsigned long) rel->r_offset);
bfd_set_error (bfd_error_bad_value); bfd_set_error (bfd_error_bad_value);

@ -1,3 +1,8 @@
2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-i386.c (tc_gen_reloc): Display signed hex number in
x32 addend overflow check.
2012-05-09 H.J. Lu <hongjiu.lu@intel.com> 2012-05-09 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-i386.c (tc_gen_reloc): Use fits_in_signed_long. * config/tc-i386.c (tc_gen_reloc): Use fits_in_signed_long.

@ -9177,10 +9177,17 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
/* Check addend overflow. */ /* Check addend overflow. */
if (!fits_in_signed_long (fixp->fx_offset)) if (!fits_in_signed_long (fixp->fx_offset))
{ {
long long addend = fixp->fx_offset;
if (addend < 0)
as_bad_where (fixp->fx_file, fixp->fx_line, as_bad_where (fixp->fx_file, fixp->fx_line,
_("cannot represent relocation %s with addend %lld in x32 mode"), _("cannot represent relocation %s with "
bfd_get_reloc_code_name (code), "addend -0x%llx in x32 mode"),
(long long) fixp->fx_offset); bfd_get_reloc_code_name (code), -addend);
else
as_bad_where (fixp->fx_file, fixp->fx_line,
_("cannot represent relocation %s with "
"addend 0x%llx in x32 mode"),
bfd_get_reloc_code_name (code), addend);
} }
break; break;
case BFD_RELOC_X86_64_DTPOFF64: case BFD_RELOC_X86_64_DTPOFF64:

@ -1,3 +1,7 @@
2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
* ld-x86-64/ilp32-11.d: Updated.
2012-05-10 H.J. Lu <hongjiu.lu@intel.com> 2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
* ld-x86-64/pr13082-1a.d: Check RELACOUNT. * ld-x86-64/pr13082-1a.d: Check RELACOUNT.

@ -1,3 +1,3 @@
#as: --x32 #as: --x32
#ld: -shared -melf32_x86_64 #ld: -shared -melf32_x86_64
#error: .*addend 2147483647 in relocation R_X86_64_64 against symbol `.text' at 0x0 in section `.data.rel.local' is out of range #error: .*addend 0x7fffffff in relocation R_X86_64_64 against symbol `.text' at 0x0 in section `.data.rel.local' is out of range