This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix cgen's insert_normal() function for operating on a 64-bit host
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Sun, 05 Mar 2006 08:50:30 +0000
- Subject: [PATCH] Fix cgen's insert_normal() function for operating on a 64-bit host
Hi Guys,
I am checking in the patch below to fix another problem I have
encountered with building toolchains on a 64-bit host. This time it
is the insert_normal() function used in cgen based ports, which was
not coping gracefully with attempts to store a negative 32-bit value
into an unsigned 32-bit field.
Cheers
Nick
opcodes/ChangeLog
2006-03-05 Nick Clifton <nickc@redhat.com>
* cgen-ibld.in (insert_normal): Cope with attempts to insert a
signed 32-bit value into an unsigned 32-bit field when the host is
a 64-bit machine.
* fr30-ibld.c: Regenerate.
* frv-ibld.c: Regenerate.
* ip2k-ibld.c: Regenerate.
* iq2000-asm.c: Regenerate.
* iq2000-ibld.c: Regenerate.
* m32c-ibld.c: Regenerate.
* m32r-ibld.c: Regenerate.
* openrisc-ibld.c: Regenerate.
* xc16x-ibld.c: Regenerate.
* xstormy16-ibld.c: Regenerate.
Index: opcodes/cgen-ibld.in
===================================================================
RCS file: /cvs/src/src/opcodes/cgen-ibld.in,v
retrieving revision 1.19
diff -c -3 -p -r1.19 cgen-ibld.in
*** opcodes/cgen-ibld.in 3 Jan 2006 22:06:18 -0000 1.19
--- opcodes/cgen-ibld.in 5 Mar 2006 08:32:31 -0000
*************** insert_normal (CGEN_CPU_DESC cd,
*** 168,180 ****
else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
{
unsigned long maxval = mask;
!
! if ((unsigned long) value > maxval)
{
/* xgettext:c-format */
sprintf (errbuf,
! _("operand out of range (%lu not between 0 and %lu)"),
! value, maxval);
return errbuf;
}
}
--- 168,188 ----
else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
{
unsigned long maxval = mask;
! unsigned long val = (unsigned long) value;
!
! /* For hosts with a word size > 32 check to see if value has been sign
! extended beyond 32 bits. If so then ignore these higher sign bits
! as the user is attempting to store a 32-bit signed value into an
! unsigned 32-bit field which is allowed. */
! if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
! val &= 0xFFFFFFFF;
!
! if (val > maxval)
{
/* xgettext:c-format */
sprintf (errbuf,
! _("operand out of range (0x%lx not between 0 and 0x%lx)"),
! val, maxval);
return errbuf;
}
}