Address sizes on 64-bit MIPS targets

Thiemo Seufer ica2_ts@csv.ica.uni-stuttgart.de
Wed Mar 2 02:58:00 GMT 2005


Richard Sandiford wrote:
[snip]
> However, if the sequence is:
> 
>         dla     $2,0xa8000000000000
>         lw      $2,0x100000($2)
> 
> then the lw will use 32-bit address arithmetic:
> 
>         lui     $1,0x10
>         addu    $1,$1,$2
>         lw      $2,0($1)
> 
> and the behaviour will be unpredictable.

Which isn't exactly a problem, because 0xa8000000000000 is an invalid
address for n32. For 32bit sign-extended addresses it works fine.

> The existing dejagnu testcase
> explicitly tests for this, so I assume it's deliberate, but it seems
> pretty dangerous to me.
> 
> I suppose one justification for using "addu" might be that addresses
> should stay within the 32-bit address space for n32 and o64, even if
> the calculation overflows.  But suppose we have a (non-macro) instruction
> with a 16-bit offset:
> 
>         lw      $2,0x1000($2)
> 
> The behaviour of this instruction is unpredicatable for 32-bit address
> spaces on 64-bit targets if $2 + 0x1000 overflows (for example, if
> $2 == 0x7ffffff0).

What is unpredictable there? It will point to the start of CKSEG0, and
trigger an address exception.

[snip]
> I'd like to change things so that:
> 
>     - "dla"s with no symbolic component use 64-bit arithmetic
>     - "la"s with no symbolic component use 32-bit arithmetic
>     - "la"s and "dla"s with a symbolic component use 64-bit arithmetic
>       iff HAVE_64BIT_ADDRESSES (i.e. they use whatever the ABI dictates). [*]
> 
>     - loads and stores with no symbolic component use 64-bit arithmetic
>       iff HAVE_64BIT_GPRS.
>     - loads and stores with a symbolic component use 64-bit arithmetic
>       iff HAVE_64BIT_ADDRESSES. [*]

Instead of changing the behaviour of this already fragile hack I would
prefer an explicit -msym32 switch for ABI N64. This would also avoid
relocation overflows due to the ELF32 format, and has the nice side
effect of an instantly working Linux module loader. :-)

(There's little hope to get working modules with N64-in-ELF32, it would
need massive changes in the architecture independent implementation.)


Thiemo



More information about the Binutils mailing list