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]

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


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