I'm trying to use a label as the offset in base-offset addressing mode,
for accessing a global variable in a shellcode-like environment. The base address of the code and data is stored in $s7
, and I'm trying to do this:
# global variable @ offset 20 in code,
foobar: .word <non-constant value>
# ...
lw $s0, foobar($s7)
And then getting the assembler to translate this to lw $t0, 20($s7)
. Instead, when compiling without special options it takes a detour via $gp
. Similarily, when using -mno-abicalls
or -mno-shared
, the lw
is translated to:
lui $s0, 0x0
addu $s0, $s0, $s7
lw $s0, 20($s0)
Is there any way to get it to interpret foobar
as an immediate value, just like when doing addiu $t0, $t1, foobar
, which is translated to addiu $t0, $t1, 20
as expected?
Digging through the docs hasn't yielded anything useful so far.
Thanks in advance!