This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Bad MIPS address arithmetic
- From: "Paul Koning" <Paul_Koning at Dell dot com>
- To: <binutils at sourceware dot org>
- Date: Mon, 10 May 2010 17:17:34 -0400
- Subject: Bad MIPS address arithmetic
I spotted this in binutils 2.18.
Given the source file:
foo: ld $v0,40000($sp)
jr $ra
The resulting code is:
lui v0, 1
addu v0, v0, sp
jr ra
ld v0, -25536(sp)
The problem is that this produces wrong addresses in machines with 64
bit registers, if the current sp is 0x7fff0000 or higher. If so, the
addu produces 0xffffffff8000nnnn in v0, and the ld then references
0xffffffff7fffnnnn which is not likely to be a valid address.
It seems that daddu rather than addu should be used here, for O64 (and
probably N32) ABIs.
paul