This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: mips-tdep.c: Sign-extend pointers for n32
On Wed, 19 Dec 2007, Daniel Jacobowitz wrote:
> What happens to an 8-bit unsigned char? How about an 8-bit signed
> char?
Hmm, you have made me wonder... Obviously 32-bit integer quantities are
special -- they are always sign-extended so that 32-bit ALU operations may
be used on them. There is this statement in the ABI document:
"All integer parameters are promoted (that is, sign- or zero-extended to
64-bit integers and passed in a single register). Typically, no code is
required for the promotion."
This note about no code requirement may be misleading -- this may be true
for the run time, because the use of "lb/lbu/lh/lhu" as appropriate would
have had the effect of doing the correct extension when the value was
fetched into a register originally, but here we are in a different
position as it is GDB that is the caller. Let me dig through the
document... Nothing relevant apparently found.
But in practice it should not matter -- however you represent 8-bit and
16-bit quantities you cannot overflow into the 64-bit data space as with a
flip of the bit #31 the upper 32 bits follow and when a result is written
back to memory or is otherwise finally processed (like output in a textual
form) it has to be masked to its data width again (obviously "sb/sh" do
this implicitly). So I believe the change is correct as it is and the
question is academic. Let me know if you think otherwise.
> What ABI is that? I thought none of the ELF targets used n32 or n64,
> but maybe SDE is an exception.
N32, as documented in "MIPSpro N32 ABI Handbook" from SGI. I can chase a
link if you cannot locate the PDF. The SDE target uses it as the default
64-bit ABI implied by the "-mips64" switch.
Maciej