Patch: Add a stop bit in alignment for alloc.
H. J. Lu
hjl@lucon.org
Mon Mar 1 20:57:00 GMT 2004
On Wed, Feb 18, 2004 at 02:05:35PM -0800, David Mosberger wrote:
>
> >> >> It crashes with IP=0xa000000100320ec0 due to the fact that the "alloc"
> >> >> is not the first instruction in the instruction-group. The
> >> >> corresponding source code looks like this:
>
> Jim> It might be worthwhile to submit a gcc bugzilla bug report for this, as
> Jim> I am unlikely to look into this anytime soon.
>
> I'll wait to see what HJ has to say. It's clearly an important bug
> because it will silently lead to bad code.
This is the patch for the assembler bug. At least, kernel won't crash.
Ok to instal?
H.J.
-------------- next part --------------
2004-03-01 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-ia64.c (ia64_handle_align): Add a stop bit for
alloc.
--- gas/config/tc-ia64.c.alloc 2004-02-24 09:32:19.000000000 -0800
+++ gas/config/tc-ia64.c 2004-03-01 12:33:31.000000000 -0800
@@ -10823,9 +10823,14 @@ ia64_handle_align (fragp)
static const unsigned char le_nop[]
= { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
+ static const unsigned char le_nop_stop[]
+ = { 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
int bytes;
char *p;
+ const unsigned char *nop = le_nop;
+ bfd_vma i0;
if (fragp->fr_type != rs_align_code)
return;
@@ -10833,6 +10838,20 @@ ia64_handle_align (fragp)
bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
p = fragp->fr_literal + fragp->fr_fix;
+ if (fragp->fr_next->fr_fix >= 8)
+ {
+ /* Get the first instruction of the next bundle. */
+ i0 = bfd_get_64 (stdoutput,
+ (bfd_byte *) fragp->fr_next->fr_literal);
+ i0 = (i0 >> 5) & 0x1ffffffffffLL;
+
+ /* If the next instruction is alloc, we have to make sure
+ there is a stop bit before it so that alloc is the first
+ instruction of the instruction group. */
+ if ((i0 & 0x1ff80000000LL) == 0x2c00000000)
+ nop = le_nop_stop;
+ }
+
/* Make sure we are on a 16-byte boundary, in case someone has been
putting data into a text section. */
if (bytes & 15)
@@ -10845,7 +10864,7 @@ ia64_handle_align (fragp)
}
/* Instruction bundles are always little-endian. */
- memcpy (p, le_nop, 16);
+ memcpy (p, nop, 16);
fragp->fr_var = 16;
}
More information about the Binutils
mailing list