[MIPS PATCH RFA] fix serious problem w/ MIPS .cprestore.
Thiemo Seufer
ica2_ts@csv.ica.uni-stuttgart.de
Sat Sep 14 21:44:00 GMT 2002
cgd@broadcom.com wrote:
[snip]
> i think the .cpreturn handling is similarly broken, but it's never
> bit me, I don't know how to use it, and there don't seem to be
> existing tests for .cpreturn in the testsuite so i don't have anything
> to copy!!!
Yes, .cpsetup/.cpreturn has the same problem. I'll fix it when you
have committed this patch.
[snip]
> diff -N testsuite/gas/mips/mips-abi32-pic2.s
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ testsuite/gas/mips/mips-abi32-pic2.s 14 Sep 2002 06:22:13 -0000
> @@ -0,0 +1,89 @@
> +
> + .text
> + .ent func1
> +func1:
> + .frame $sp,0,$31
> + .set noreorder
> + .cpload $25 # 0000 lui gp,hi(_gp_disp)
> + # 0004 addiu gp,gp,lo(_gp_disp)
> + # 0008 addu gp,gp,t9
> + .set reorder
> + .cprestore 8 # 000c sw gp,8(sp)
> +
> + jal end # 0048 lw t9,got(.text)(gp)
> + # 004c nop
> + # 0050 addiu t9,t9,lo(end)
> + # 0054 jalr t9
> + # 0058 nop
> + # 005c lw gp,8(sp)
> +
> + # avoid confusion: without something here, the lw above might be
> + # put into the delay slot for the jalr below!
> + nop
> +
> + jal end # 0054 jalr t9
> + # 0058 nop
> + # 005c lw gp,8(sp)
> + .end func1
To avoid confusion: What about adding a proper function epilogue
at the function's end?
> +
> +
> + .text
> + .ent func2
> +func2:
> + .frame $sp,0,$31
> + .set noreorder
> + .cpload $25 # 0000 lui gp,hi(_gp_disp)
> + # 0004 addiu gp,gp,lo(_gp_disp)
> + # 0008 addu gp,gp,t9
> + .set reorder
> + .cprestore 32768 # 000c sw gp,8(sp)
^^^^^ ^
Which one to believe? :-)
> +
> + jal end # 0048 lw t9,got(.text)(gp)
> + # 004c nop
> + # 0050 addiu t9,t9,lo(end)
> + # 0054 jalr t9
> + # 0058 nop
> + # 005c lw gp,8(sp)
^
Likewise for the rest below.
Thiemo
More information about the Binutils
mailing list