aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-07-19 15:36:58 +0930
committerAlan Modra <amodra@gmail.com>2019-07-19 18:01:25 +0930
commitc213164ad2505cba5263602b7f9fa9a4dd1adf39 (patch)
tree6ae2722172b2b22884319957004388e0402dd90a /include
parent7a708984176cc2d247d7dd96d84c7d7501bae6eb (diff)
downloadgdb-c213164ad2505cba5263602b7f9fa9a4dd1adf39.zip
gdb-c213164ad2505cba5263602b7f9fa9a4dd1adf39.tar.gz
gdb-c213164ad2505cba5263602b7f9fa9a4dd1adf39.tar.bz2
[PowerPC64] pc-relative TLS relocations
This patch supports using pcrel instructions in TLS code sequences. A number of new relocations are needed, gas operand modifiers to generate those relocations, and new TLS optimisation. For optimisation it turns out that the new pcrel GD and LD sequences can be distinguished from the non-pcrel GD and LD sequences by there being different relocations on the new sequence. The final "add ra,rb,13" on IE sequences similarly needs a new relocation, or as I chose, a modification of R_PPC64_TLS. On pcrel IE code, the R_PPC64_TLS points one byte into the "add" instruction rather than being on the instruction boundary. GD: pla 3,z@got@tlsgd@pcrel # R_PPC64_GOT_TLSGD34 bl __tls_get_addr@notoc(z@tlsgd) # R_PPC64_TLSGD and R_PPC64_REL24_NOTOC edited to IE pld 3,z@got@tprel@pcrel add 3,3,13 edited to LE paddi 3,13,z@tprel nop LD: pla 3,z@got@tlsld@pcrel # R_PPC64_GOT_TLSLD34 bl __tls_get_addr@notoc(z@tlsld) # R_PPC64_TLSLD and R_PPC64_REL24_NOTOC .. paddi 9,3,z2@dtprel pld 10,z3@got@dtprel@pcrel add 10,10,3 edited to LE paddi 3,13,0x1000 nop IE: pld 9,z@got@tprel@pcrel # R_PPC64_GOT_TPREL34 add 3,9,z@tls@pcrel # R_PPC64_TLS at insn+1 ldx 4,9,z@tls@pcrel lwax 5,9,z@tls@pcrel stdx 5,9,z@tls@pcrel edited to LE paddi 9,13,z@tprel nop ld 4,0(9) lwa 5,0(9) std 5,0(9) LE: paddi 10,13,z@tprel include/ * elf/ppc64.h (R_PPC64_TPREL34, R_PPC64_DTPREL34), (R_PPC64_GOT_TLSGD34, R_PPC64_GOT_TLSLD34), (R_PPC64_GOT_TPREL34, R_PPC64_GOT_DTPREL34): Define. (IS_PPC64_TLS_RELOC): Include new tls relocs. bfd/ * reloc.c (BFD_RELOC_PPC64_TPREL34, BFD_RELOC_PPC64_DTPREL34), (BFD_RELOC_PPC64_GOT_TLSGD34, BFD_RELOC_PPC64_GOT_TLSLD34), (BFD_RELOC_PPC64_GOT_TPREL34, BFD_RELOC_PPC64_GOT_DTPREL34), (BFD_RELOC_PPC64_TLS_PCREL): New pcrel tls relocs. * elf64-ppc.c (ppc64_elf_howto_raw): Add howtos for pcrel tls relocs. (ppc64_elf_reloc_type_lookup): Translate pcrel tls relocs. (must_be_dyn_reloc, dec_dynrel_count): Add R_PPC64_TPREL64. (ppc64_elf_check_relocs): Support pcrel tls relocs. (ppc64_elf_tls_optimize, ppc64_elf_relocate_section): Likewise. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas/ * config/tc-ppc.c (ppc_elf_suffix): Map "tls@pcrel", "got@tlsgd@pcrel", "got@tlsld@pcrel", "got@tprel@pcrel", and "got@dtprel@pcrel". (fixup_size, md_assemble): Handle pcrel tls relocs. (ppc_force_relocation, ppc_fix_adjustable): Likewise. (md_apply_fix, tc_gen_reloc): Likewise. ld/ * testsuite/ld-powerpc/tlsgd.d, * testsuite/ld-powerpc/tlsgd.s, * testsuite/ld-powerpc/tlsie.d, * testsuite/ld-powerpc/tlsie.s, * testsuite/ld-powerpc/tlsld.d, * testsuite/ld-powerpc/tlsld.s: New tests. * testsuite/ld-powerpc/powerpc.exp: Run them.
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog7
-rw-r--r--include/elf/ppc64.h10
2 files changed, 15 insertions, 2 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index 07e0c5c..bb5abb1 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-19 Alan Modra <amodra@gmail.com>
+
+ * elf/ppc64.h (R_PPC64_TPREL34, R_PPC64_DTPREL34),
+ (R_PPC64_GOT_TLSGD34, R_PPC64_GOT_TLSLD34),
+ (R_PPC64_GOT_TPREL34, R_PPC64_GOT_DTPREL34): Define.
+ (IS_PPC64_TLS_RELOC): Include new tls relocs.
+
2019-07-18 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (ECTF_NOTFUNC): Fix description.
diff --git a/include/elf/ppc64.h b/include/elf/ppc64.h
index e90c7fd..226c989 100644
--- a/include/elf/ppc64.h
+++ b/include/elf/ppc64.h
@@ -181,6 +181,12 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type)
RELOC_NUMBER (R_PPC64_REL16_HIGHESTA34, 143)
RELOC_NUMBER (R_PPC64_D28, 144)
RELOC_NUMBER (R_PPC64_PCREL28, 145)
+ RELOC_NUMBER (R_PPC64_TPREL34, 146)
+ RELOC_NUMBER (R_PPC64_DTPREL34, 147)
+ RELOC_NUMBER (R_PPC64_GOT_TLSGD34, 148)
+ RELOC_NUMBER (R_PPC64_GOT_TLSLD34, 149)
+ RELOC_NUMBER (R_PPC64_GOT_TPREL34, 150)
+ RELOC_NUMBER (R_PPC64_GOT_DTPREL34, 151)
#ifndef RELOC_MACROS_GEN_FUNC
/* Relocation only used internally by gas or ld. If you need to use
@@ -218,8 +224,8 @@ END_RELOC_NUMBERS (R_PPC64_max)
#define IS_PPC64_TLS_RELOC(R) \
(((R) >= R_PPC64_TLS && (R) <= R_PPC64_DTPREL16_HIGHESTA) \
- || ((R) >= R_PPC64_TPREL16_HIGH && (R) <= R_PPC64_DTPREL16_HIGHA))
-
+ || ((R) >= R_PPC64_TPREL16_HIGH && (R) <= R_PPC64_DTPREL16_HIGHA) \
+ || ((R) >= R_PPC64_TPREL34 && (R) <= R_PPC64_GOT_DTPREL34))
/* e_flags bits specifying ABI.
1 for original function descriptor using ABI,