This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[rs6000/rfc] -fPIC vs TLS
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Mar 2006 15:20:27 -0800
- Subject: [rs6000/rfc] -fPIC vs TLS
The code we emit for TLS with -fPIC triggers the linker to
turn on old-abi executable got. I'm trying to figure out
the best way to rearrange things for TARGET_SECURE_PLT.
First of all, it seems like the existing code for the old
abi is being unnecessarily obtuse.
bcl 20,31,2f
1: .long _GLOBAL_OFFSET_TABLE_-$
2:
mflr 1
lwz 2,0(1)
add 3,2,1
Isn't this an extremely long-winded way of loading _GOT_?
And, it turns out that the existance of that pc-relative
relocation vs _GOT_ is what causes the linker to go into
its old-style PLT mode.
For the case of secure-plt, I can't think of anything more
efficient than just treating _GOT_ as any other local symbol.
Which means (at least for the moment), just dropping its
address into the .got2 section and reading it from there.
A possible improvement for old-abi: as I understand it, -fPIC
code still does have a regular .got section, even if most bits
go into the local .got2 subsections. This would mean that the
best way to get this address is with the plain old
load_toc_v4_pic_si pattern; that is
bl _GLOBAL_OFFSET_TABLE_@local-4
mflr 3
Comments?
r~
Index: rs6000.c
===================================================================
--- rs6000.c (revision 111910)
+++ rs6000.c (working copy)
@@ -3108,36 +3108,12 @@ rs6000_legitimize_tls_address (rtx addr,
else
{
if (flag_pic == 1)
- got = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
+ got = pic_offset_table_rtx;
else
{
rtx gsym = rs6000_got_sym ();
got = gen_reg_rtx (Pmode);
- if (flag_pic == 0)
- rs6000_emit_move (got, gsym, Pmode);
- else
- {
- rtx tempLR, tmp3, mem;
- rtx first, last;
-
- tempLR = gen_reg_rtx (Pmode);
- tmp1 = gen_reg_rtx (Pmode);
- tmp2 = gen_reg_rtx (Pmode);
- tmp3 = gen_reg_rtx (Pmode);
- mem = gen_const_mem (Pmode, tmp1);
-
- first = emit_insn (gen_load_toc_v4_PIC_1b (tempLR, gsym));
- emit_move_insn (tmp1, tempLR);
- emit_move_insn (tmp2, mem);
- emit_insn (gen_addsi3 (tmp3, tmp1, tmp2));
- last = emit_move_insn (got, tmp3);
- REG_NOTES (last) = gen_rtx_EXPR_LIST (REG_EQUAL, gsym,
- REG_NOTES (last));
- REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
- REG_NOTES (first));
- REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
- REG_NOTES (last));
- }
+ rs6000_emit_move (got, gsym, Pmode);
}
}