This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Check 64-bit relocation addend overflow for x32
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 10 May 2012 17:52:05 -0700
- Subject: Re: PATCH: Check 64-bit relocation addend overflow for x32
- References: <20120510032741.GA13387@intel.com> <20120510204818.GA17989@intel.com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
I checked in this patch to use int and bfd_signed_vma in x32 addend
overflow check
H.J.
---
Index: gas/ChangeLog
===================================================================
RCS file: /cvs/src/src/gas/ChangeLog,v
retrieving revision 1.4726
diff -u -p -r1.4726 ChangeLog
--- gas/ChangeLog 10 May 2012 20:46:31 -0000 1.4726
+++ gas/ChangeLog 11 May 2012 00:49:46 -0000
@@ -1,5 +1,10 @@
2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
+ * config/tc-i386.c (tc_gen_reloc): Use bfd_signed_vma in x32
+ addend overflow check.
+
+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.
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.492
diff -u -p -r1.492 tc-i386.c
--- gas/config/tc-i386.c 10 May 2012 20:46:31 -0000 1.492
+++ gas/config/tc-i386.c 11 May 2012 00:49:47 -0000
@@ -9177,16 +9177,18 @@ tc_gen_reloc (asection *section ATTRIBUT
/* Check addend overflow. */
if (!fits_in_signed_long (fixp->fx_offset))
{
- long long addend = fixp->fx_offset;
+ bfd_signed_vma addend = fixp->fx_offset;
if (addend < 0)
as_bad_where (fixp->fx_file, fixp->fx_line,
_("cannot represent relocation %s with "
- "addend -0x%llx in x32 mode"),
+ "addend -0x%" BFD_VMA_FMT "x in x32 "
+ "mode"),
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"),
+ "addend 0x%" BFD_VMA_FMT "x in x32 "
+ "mode"),
bfd_get_reloc_code_name (code), addend);
}
break;
Index: bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.5678
diff -u -p -r1.5678 ChangeLog
--- bfd/ChangeLog 11 May 2012 00:01:58 -0000 1.5678
+++ bfd/ChangeLog 11 May 2012 00:49:47 -0000
@@ -1,3 +1,8 @@
+2012-05-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Use int in x32
+ addend overflow check.
+
2012-05-10 DJ Delorie <dj@redhat.com>
* elf32-rx.c (rx_elf_object_p): Ignore empty segments.
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.261
diff -u -p -r1.261 elf64-x86-64.c
--- bfd/elf64-x86-64.c 10 May 2012 20:46:33 -0000 1.261
+++ bfd/elf64-x86-64.c 11 May 2012 00:49:47 -0000
@@ -3686,7 +3686,7 @@ elf_x86_64_relocate_section (bfd *output
!= (rel->r_addend & 0x80000000))
{
const char *name;
- long addend = rel->r_addend;
+ int addend = rel->r_addend;
if (h && h->root.root.string)
name = h->root.root.string;
else
@@ -3694,7 +3694,7 @@ elf_x86_64_relocate_section (bfd *output
sym, NULL);
if (addend < 0)
(*_bfd_error_handler)
- (_("%B: addend -0x%lx in relocation %s against "
+ (_("%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,
@@ -3702,7 +3702,7 @@ elf_x86_64_relocate_section (bfd *output
name, (unsigned long) rel->r_offset);
else
(*_bfd_error_handler)
- (_("%B: addend 0x%lx in relocation %s against "
+ (_("%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,