This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add a warning for some problematic MIPS constants


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]