aboutsummaryrefslogtreecommitdiff
path: root/include/elf
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-04-09 09:25:10 +0930
committerAlan Modra <amodra@gmail.com>2018-04-09 17:25:20 +0930
commit23cedd1dc90d05c4b80d4a4b000ed5f37b9c3268 (patch)
treef2973eade7f265f64490faa75ed9fa36d229f39b /include/elf
parent2d7ad24e8726ba4c45c9e67be08223a146a837ce (diff)
downloadgdb-23cedd1dc90d05c4b80d4a4b000ed5f37b9c3268.zip
gdb-23cedd1dc90d05c4b80d4a4b000ed5f37b9c3268.tar.gz
gdb-23cedd1dc90d05c4b80d4a4b000ed5f37b9c3268.tar.bz2
PowerPC inline PLT call support
In addition to the existing relocs we need two more to mark all instructions in the call sequence, PLTCALL on the call itself (plus the toc restore insn for ppc64), and PLTSEQ on others. All relocations in a particular sequence have the same symbol. Example ppc64 ELFv2 assembly: .reloc .,R_PPC64_PLTSEQ,puts std 2,24(1) addis 12,2,puts@plt@ha # .reloc .,R_PPC64_PLT16_HA,puts ld 12,puts@plt@l(12) # .reloc .,R_PPC64_PLT16_LO_DS,puts .reloc .,R_PPC64_PLTSEQ,puts mtctr 12 .reloc .,R_PPC64_PLTCALL,puts bctrl ld 2,24(1) Example ppc32 -fPIC assembly: addis 12,30,puts+32768@plt@ha # .reloc .,R_PPC_PLT16_HA,puts+0x8000 lwz 12,12,puts+32768@plt@l # .reloc .,R_PPC_PLT16_LO,puts+0x8000 .reloc .,R_PPC_PLTSEQ,puts+32768 mtctr 12 .reloc .,R_PPC_PLTCALL,puts+32768 bctrl Marking sequences like this allows the linker to convert them to nops and a direct call if the target symbol turns out to be local. When the call is __tls_get_addr, each relocation shown above is paired with an R_PPC*_TLSLD or R_PPC*_TLSGD reloc to additionally mark the sequence for possible TLS optimization. The TLSLD or TLSGD relocs are emitted first. include/ * elf/ppc.h (R_PPC_PLTSEQ, R_PPC_PLTCALL): Define. * elf/ppc64.h (R_PPC64_PLTSEQ, R_PPC64_PLTCALL): Define. bfd/ * elf32-ppc.c (ppc_elf_howto_raw): Add PLTSEQ and PLTCALL howtos. (is_plt_seq_reloc): New function. (ppc_elf_check_relocs): Handle PLTSEQ and PLTCALL relocs. (ppc_elf_tls_optimize): Handle inline plt call sequence. (ppc_elf_relax_section): Handle PLTCALL reloc. (ppc_elf_relocate_section): Nop out inline plt call sequence when resolving locally. * elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_PLTSEQ and R_PPC64_PLTCALL entries. Comment R_PPC64_TOCSAVE. (has_tls_get_addr_call): Correct comment. (is_branch_reloc): Add PLTCALL. (is_plt_seq_reloc): New function. (ppc64_elf_check_relocs): Handle PLT16_LO_DS reloc. Set has_tls_reloc for R_PPC64_TLSGD and R_PPC64_TLSLD. Create plt entry for R_PPC64_PLTCALL. (ppc64_elf_tls_optimize): Handle inline plt call sequence. (ppc_type_of_stub): Handle PLTCALL reloc. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_relocate_section): Set "can_plt_call" for PLTCALL reloc insn. Nop out inline plt call sequence when resolving locally. Handle __tls_get_addr inline plt call optimization. elfcpp/ * powerpc.h (R_POWERPC_PLTSEQ, R_POWERPC_PLTCALL): Define. gold/ * powerpc.cc (Target_powerpc::Track_tls::maybe_skip_tls_get_addr_call): Handle inline plt sequence relocs. (Stub_table::Plt_stub_key::Plt_stub_key): Likewise. (Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Likewise. (Target_powerpc::Relocate::relocate): Likewise.
Diffstat (limited to 'include/elf')
-rw-r--r--include/elf/ppc.h4
-rw-r--r--include/elf/ppc64.h4
2 files changed, 8 insertions, 0 deletions
diff --git a/include/elf/ppc.h b/include/elf/ppc.h
index 3de200c..c48733e 100644
--- a/include/elf/ppc.h
+++ b/include/elf/ppc.h
@@ -134,6 +134,10 @@ START_RELOC_NUMBERS (elf_ppc_reloc_type)
RELOC_NUMBER (R_PPC_EMB_BIT_FLD, 115)
RELOC_NUMBER (R_PPC_EMB_RELSDA, 116)
+/* Marker reloc for inline plt call insns. */
+ RELOC_NUMBER (R_PPC_PLTSEQ, 119)
+ RELOC_NUMBER (R_PPC_PLTCALL, 120)
+
/* PowerPC VLE relocations. */
RELOC_NUMBER (R_PPC_VLE_REL8, 216)
RELOC_NUMBER (R_PPC_VLE_REL15, 217)
diff --git a/include/elf/ppc64.h b/include/elf/ppc64.h
index 04a7432..501aebc 100644
--- a/include/elf/ppc64.h
+++ b/include/elf/ppc64.h
@@ -154,6 +154,10 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type)
RELOC_NUMBER (R_PPC64_ADDR64_LOCAL, 117)
RELOC_NUMBER (R_PPC64_ENTRY, 118)
+/* Marker reloc for inline plt call insns. */
+ RELOC_NUMBER (R_PPC64_PLTSEQ, 119)
+ RELOC_NUMBER (R_PPC64_PLTCALL, 120)
+
#ifndef RELOC_MACROS_GEN_FUNC
/* Relocation only used internally by ld. If you need to use these
reloc numbers, you can change them to some other unused value