This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Add a warning for some problematic MIPS constants
- From: Jim Wilson <wilson at specifix dot com>
- To: Daniel Jacobowitz <drow at false dot org>
- Cc: binutils at sourceware dot org
- Date: Wed, 19 Sep 2007 11:10:30 -0700
- Subject: Re: Add a warning for some problematic MIPS constants
- References: <20070919141543.GA30797@caradoc.them.org>
On Wed, 2007-09-19 at 10:15 -0400, Daniel Jacobowitz wrote:
> The cases I'm trying to warn about are instructions that do not have a
> clear explicit width. For instance, "li" and "dli" are obvious, but
> bne and sltu are not. If you write "bne $4,0x80000000,label" gas
> zero extends the constant, and Diab sign extends it.
I've seen a similar problem with load/store instructions. If you are
trying to read memory mapped hardware registers in high memory, you
might have an instruction like
lw $4, 0x80000000
Compile this with a mips-elf toolchain, run it on 64-bit hardware, and
it loads from the address 0xffffffff80000000. Compile this with a
current mips64-elf toolchain, run it on 64-bit hardware, and it loads
from the address 0x0000000080000000. Compile it with an old mips64-elf
toolchain, and it loads from 0xffffffff80000000. This tripped up one of
our customers. The handling of constant addresses here is independent
of whether this is a byte, half-word, word, or double-word load.
I agree that the current gas behaviour makes sense. But if we are going
to warn about the bne/sltu cases, then I think we should warn about the
lw/sw/etc cases too. I tried your patch, and it doesn't handle the
load/store instruction cases.
I don't have access to the Diab assembler, but it presumably has the
same issue here.
--
Jim Wilson, GNU Tools Support, http://www.specifix.com