This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: ld/1567: 64-bit vma overflow signalled from 32-bit-target address-wrap


On Fri, Oct 28, 2005 at 10:10:07AM -0700, H. J. Lu wrote:
> On Fri, Oct 28, 2005 at 07:01:21PM +0200, Hans-Peter Nilsson wrote:
> > > Date: Fri, 28 Oct 2005 09:37:15 -0700
> > > From: "H. J. Lu" <hjl@lucon.org>
> > 
> > > I don't think
> > > 
> > > http://sourceware.org/ml/binutils/2005-10/msg00427.html
> > > 
> > > is correct. complain_overflow_bitfield will fail for all 32bit targets
> > > with 32bit RELA relocations when 64bit bfd_vma is used.
> > 
> > Well, I *did* indicate that something in the direction you're
> > heading was better (thanks for looking into it)...
> > 
> > > _bfd_relocate_contents has support for 32bit REL relocations, but not
> > > RELA relocations. This patch should work.
> > 
> > ... but it's not really *wrong* to disable overflow-checking on
> > that reloc in elf32-cris.c because there *can be* no overflow
> > for 32-bit arithmetic in 32-bit ELF.  (Note that "32-bit" is the
> > GCC spelling convention, so we'd better use that.)
> > 
> > So, I'd rather keep the elf32-cris.c bits, don't apply that
> > part, please.
> 
> I will leave it to you.
> 
> 

I don't think what I was thinking. I meant to check field bits <=
address bits. Here is the updated patch.


H.J.
---
2005-10-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/1567
	* reloc.c (_bfd_relocate_contents): Support 32bit target with
	64bit bfd_vma when checking complain_overflow_bitfield.

--- bfd/reloc.c.overflow	2005-10-28 09:29:36.000000000 -0700
+++ bfd/reloc.c	2005-10-28 10:13:09.000000000 -0700
@@ -1514,6 +1514,10 @@ _bfd_relocate_contents (reloc_howto_type
 	  a >>= rightshift;
 
 	  signmask = ~ fieldmask;
+	  /* We mask with addrmask here to support 32bit target with
+	     64bit bfd_vma.  */
+	  if (howto->bitsize <= bfd_arch_bits_per_address (input_bfd))
+	    signmask &= addrmask;
 	  ss = a & signmask;
 	  if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & signmask))
 	    flag = bfd_reloc_overflow;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]