mips-tdep.c: Sign-extend pointers for n32

Daniel Jacobowitz drow@false.org
Wed Dec 19 17:08:00 GMT 2007

On Wed, Dec 19, 2007 at 04:07:13PM +0000, Maciej W. Rozycki wrote:
>  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.

I happen to know otherwise.  I once wasted several days tracking down
a bug in the Linux kernel's IP checksumming implementation which
resulted in incorrectly extended values in registers; there are MIPS
parts which really do behave unpredictably when you use 32-bit
arithmetic operations on them (specifically the Broadcom SB1).
And I believe a compiler would be justified in using such instructions
on a signed char argument.

Daniel Jacobowitz

More information about the Gdb-patches mailing list