This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Relax MIPS j/jal out-of-range check
Daniel Jacobowitz wrote:
> On Wed, May 10, 2006 at 04:04:42PM +0100, Thiemo Seufer wrote:
> > > How could you get the assembler to do this? Normally you can't tell if
> > > this is going to overflow until you've linked! Linker errors are a
> > > different kettle of fish.
> > >
> > > I think the warning is just bogus, after looking at it. We're warning
> > > for "jal 0x10000000". But we don't know the location of the jal yet,
> > > so we haven't a clue if it's out of range, do we?
> >
> > The patch is correct, but our explanation was misleading: The code
> > checks for absolute addresses, and warns now if it crosses a 256 MB
> > memory area. This allows e.g. to jump between KSEG0 and KSEG1 without
> > hassles.
>
> I don't think we're communicating.
>
> drow@caradoc:~% cat a.s
> jal 0x10000000
> drow@caradoc:~% /space/fsf/mips/install/bin/mips64-linux-as a.s
> a.s: Assembler messages:
> a.s:1: Error: jump address range overflow (0x10000000)
>
> So... how can the assembler know that? If you link the file into an
> executable such that a.o(.text) is at 0x10000010, then the jal does not
> overflow.
Hm, indeed. Do you like the appended patch better? Should something
similiar go in the branch?
Thiemo
2006-05-10 Thiemo Seufer <ths@mips.com>
[ gas/ChangeLog ]
* config/tc-mips.c (append_insn): Don't check the range of j or
jal addresses.
[ gas/testsuite/ChangeLog ]
* gas/mips/jal-range.l: Don't check the range of j or jal
addresses.
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.333
diff -u -p -r1.333 tc-mips.c
--- gas/config/tc-mips.c 9 May 2006 14:16:49 -0000 1.333
+++ gas/config/tc-mips.c 10 May 2006 16:50:30 -0000
@@ -2415,9 +2428,6 @@ append_insn (struct mips_cl_insn *ip, ex
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)
- as_warn (_("jump address range overflow (0x%lx)"),
- (unsigned long) address_expr->X_add_number);
ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0x3ffffff;
break;
@@ -2425,9 +2435,6 @@ append_insn (struct mips_cl_insn *ip, ex
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)
- as_warn (_("jump address range overflow (0x%lx)"),
- (unsigned long) address_expr->X_add_number);
ip->insn_opcode |=
(((address_expr->X_add_number & 0x7c0000) << 3)
| ((address_expr->X_add_number & 0xf800000) >> 7)
Index: gas/testsuite/gas/mips/jal-range.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/jal-range.l,v
retrieving revision 1.3
diff -u -p -r1.3 jal-range.l
--- gas/testsuite/gas/mips/jal-range.l 9 May 2006 14:16:50 -0000 1.3
+++ gas/testsuite/gas/mips/jal-range.l 10 May 2006 16:50:31 -0000
@@ -1,4 +1,4 @@
.*: Assembler messages:
.*:4: Error: jump to misaligned address \(0x1\)
.*:6: Error: jump to misaligned address \(0xfffffff\)
-.*:7: Warning: jump address range overflow \(0x10000000\)
+.*:8: Error: jump to misaligned address \(0x10000003\)
Index: gas/testsuite/gas/mips/jal-range.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/jal-range.s,v
retrieving revision 1.2
diff -u -p -r1.2 jal-range.s
--- gas/testsuite/gas/mips/jal-range.s 26 Sep 2002 09:00:08 -0000 1.2
+++ gas/testsuite/gas/mips/jal-range.s 10 May 2006 16:50:31 -0000
@@ -1,7 +1,8 @@
-# Source file use to test border cases of jumps
+# Source file used to test misaligned targets of absolute jumps
jal 0x0
jal 0x1
jal 0xffffffc
jal 0xfffffff
jal 0x10000000
+ jal 0x10000003