This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] New testcase for MIPS jal overflow/misalignment mismatch
cgd@broadcom.com wrote:
> At Tue, 17 Sep 2002 08:25:00 +0000 (UTC), "Thiemo Seufer" wrote:
> > + jal 0x0
> > + jal 0x7fffffc
> > + jal 0x7fffffd
> > + jal 0x8000000
>
> OK, i'm puzzled about these.
>
> jal (and j) takes a 28 bit PC index-into-segment, that it puts into a
> 26-bit field.
>
> None of these go into the 29th address bit, so I don't understand why
> any would overflow.
If the input address does not fit in these 28 bit, the resulting
truncation would lead to bad code (it's unlikely to be the intended
result).
> from the code (pre-existing):
>
> if (address_expr->X_add_number & ~0xfffffff
> || address_expr->X_add_number > 0x7fffffc)
> as_bad (_("jump address range overflow (0x%lx)"),
> (unsigned long) address_expr->X_add_number);
> ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0x3ffffff;
>
> why the 7fffffc here? shouldn't that be ffffffc ?
Hm, seem like I've done this with little thought. This patch fixes it.
Thiemo
2002-09-18 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
/gas/ChangeLog
* config/tc-mips.c (append_insn): Fix jump overflow check.
/gas/testsuite/ChangeLog
* gas/mips/jal-range.s: Fix jump overflow check.
* gas/mips/jal-range.l: Likewise.
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/config/tc-mips.c source/gas/config/tc-mips.c
--- source-orig/gas/config/tc-mips.c Tue Sep 17 11:35:47 2002
+++ source/gas/config/tc-mips.c Wed Sep 18 10:22:32 2002
@@ -1843,8 +1857,7 @@ append_insn (place, ip, address_expr, re
if ((address_expr->X_add_number & 3) != 0)
as_bad (_("jump to misaligned address (0x%lx)"),
(unsigned long) address_expr->X_add_number);
- if (address_expr->X_add_number & ~0xfffffff
- || address_expr->X_add_number > 0x7fffffc)
+ if (address_expr->X_add_number & ~0xfffffff)
as_bad (_("jump address range overflow (0x%lx)"),
(unsigned long) address_expr->X_add_number);
ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0x3ffffff;
@@ -1854,8 +1867,7 @@ append_insn (place, ip, address_expr, re
if ((address_expr->X_add_number & 3) != 0)
as_bad (_("jump to misaligned address (0x%lx)"),
(unsigned long) address_expr->X_add_number);
- if (address_expr->X_add_number & ~0xfffffff
- || address_expr->X_add_number > 0x7fffffc)
+ if (address_expr->X_add_number & ~0xfffffff)
as_bad (_("jump address range overflow (0x%lx)"),
(unsigned long) address_expr->X_add_number);
ip->insn_opcode |=
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/jal-range.l source/gas/testsuite/gas/mips/jal-range.l
--- source-orig/gas/testsuite/gas/mips/jal-range.l Tue Sep 17 10:38:27 2002
+++ source/gas/testsuite/gas/mips/jal-range.l Wed Sep 18 11:10:51 2002
@@ -1,4 +1,4 @@
.*: Assembler messages:
-.*:5: Error: jump to misaligned address \(0x7fffffd\)
-.*:5: Error: jump address range overflow \(0x7fffffd\)
-.*:6: Error: jump address range overflow \(0x8000000\)
+.*:4: Error: jump to misaligned address \(0x1\)
+.*:6: Error: jump to misaligned address \(0xfffffff\)
+.*:7: Error: jump address range overflow \(0x10000000\)
diff -BurpNX /bigdisk/src/gcc-exclude source-orig/gas/testsuite/gas/mips/jal-range.s source/gas/testsuite/gas/mips/jal-range.s
--- source-orig/gas/testsuite/gas/mips/jal-range.s Tue Sep 17 10:38:27 2002
+++ source/gas/testsuite/gas/mips/jal-range.s Wed Sep 18 10:23:29 2002
@@ -1,6 +1,7 @@
# Source file use to test border cases of jumps
jal 0x0
- jal 0x7fffffc
- jal 0x7fffffd
- jal 0x8000000
+ jal 0x1
+ jal 0xffffffc
+ jal 0xfffffff
+ jal 0x10000000