mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
9a23f96e91
In the TLS GD/LD to LE optimization, ld replaces a sequence like addi 3,2,x@got@tlsgd R_PPC64_GOT_TLSGD16 x bl __tls_get_addr(x@tlsgd) R_PPC64_TLSGD x R_PPC64_REL24 __tls_get_addr nop with addis 3,13,x@tprel@ha R_PPC64_TPREL16_HA x addi 3,3,x@tprel@l R_PPC64_TPREL16_LO x nop When the tprel offset is small, this can be further optimized to nop addi 3,13,x@tprel nop bfd/ * elf64-ppc.c (struct ppc_link_hash_table): Add do_tls_opt. (ppc64_elf_tls_optimize): Set it. (ppc64_elf_relocate_section): Nop addis on TPREL16_HA, and convert insn on TPREL16_LO and TPREL16_LO_DS relocs to use r13 when addis would add zero. * elf32-ppc.c (struct ppc_elf_link_hash_table): Add do_tls_opt. (ppc_elf_tls_optimize): Set it. (ppc_elf_relocate_section): Nop addis on TPREL16_HA, and convert insn on TPREL16_LO relocs to use r2 when addis would add zero. gold/ * powerpc.cc (Target_powerpc::Relocate::relocate): Nop addis on TPREL16_HA, and convert insn on TPREL16_LO and TPREL16_LO_DS relocs to use r2/r13 when addis would add zero. ld/ * testsuite/ld-powerpc/tls.s: Add calls with tls markers. * testsuite/ld-powerpc/tls32.s: Likewise. * testsuite/ld-powerpc/powerpc.exp: Run tls marker tests. * testsuite/ld-powerpc/tls.d: Adjust for TPREL16_HA/LO optimization. * testsuite/ld-powerpc/tlsexe.d: Likewise. * testsuite/ld-powerpc/tlsexetoc.d: Likewise. * testsuite/ld-powerpc/tlsld.d: Likewise. * testsuite/ld-powerpc/tlsmark.d: Likewise. * testsuite/ld-powerpc/tlsopt4.d: Likewise. * testsuite/ld-powerpc/tlstoc.d: Likewise.
127 lines
2.8 KiB
ArmAsm
127 lines
2.8 KiB
ArmAsm
.section ".tbss","awT",@nobits
|
|
.global _start,gd0,ld0,ld1,ld2,ie0,le0,le1
|
|
.align 3
|
|
gd0: .space 8
|
|
ld0: .space 8
|
|
ld1: .space 8
|
|
ld2: .space 8
|
|
ie0: .space 8
|
|
le0: .space 8
|
|
le1: .space 8
|
|
|
|
.section ".tdata","awT",@progbits
|
|
.align 3
|
|
gd4: .quad 0x123456789abcdef0
|
|
ld4: .quad 0x23456789abcdef01
|
|
ld5: .quad 0x3456789abcdef012
|
|
ld6: .quad 0x456789abcdef0123
|
|
ie4: .quad 0x56789abcdef01234
|
|
le4: .quad 0x6789abcdef012345
|
|
le5: .quad 0x789abcdef0123456
|
|
|
|
.section ".opd","aw",@progbits
|
|
.p2align 3
|
|
_start:
|
|
.quad .L_start,.TOC.@tocbase,0
|
|
|
|
.text
|
|
.L_start:
|
|
#extern syms
|
|
#GD
|
|
addi 3,2,gd@got@tlsgd #R_PPC64_GOT_TLSGD16 gd
|
|
.ifdef TLSMARK
|
|
bl __tls_get_addr(gd@tlsgd) #R_PPC64_TLSGD gd
|
|
#R_PPC64_REL24 __tls_get_addr
|
|
.else
|
|
bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
|
|
.endif
|
|
nop
|
|
|
|
#LD
|
|
addi 3,2,ld@got@tlsld #R_PPC64_GOT_TLSLD16 ld
|
|
.ifdef TLSMARK
|
|
bl __tls_get_addr(ld@tlsld) #R_PPC64_TLSLD ld
|
|
#R_PPC64_REL24 __tls_get_addr
|
|
.else
|
|
bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
|
|
.endif
|
|
nop
|
|
|
|
#global syms
|
|
#GD
|
|
addi 3,2,gd0@got@tlsgd #R_PPC64_GOT_TLSGD16 gd0
|
|
.ifdef TLSMARK
|
|
bl __tls_get_addr(gd0@tlsgd) #R_PPC64_TLSGD gd0
|
|
#R_PPC64_REL24 __tls_get_addr
|
|
.else
|
|
bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
|
|
.endif
|
|
nop
|
|
|
|
#LD
|
|
addi 3,2,ld0@got@tlsld #R_PPC64_GOT_TLSLD16 ld0
|
|
.ifdef TLSMARK
|
|
bl __tls_get_addr(ld0@tlsld) #R_PPC64_TLSLD ld0
|
|
#R_PPC64_REL24 __tls_get_addr
|
|
.else
|
|
bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
|
|
.endif
|
|
nop
|
|
|
|
addi 9,3,ld0@dtprel #R_PPC64_DTPREL16 ld0
|
|
|
|
addis 9,3,ld1@dtprel@ha #R_PPC64_DTPREL16_HA ld1
|
|
lwz 10,ld1@dtprel@l(9) #R_PPC64_DTPREL16_LO ld1
|
|
|
|
ld 9,ld2@got@dtprel(2) #R_PPC64_GOT_DTPREL16_DS ld2
|
|
ldx 10,9,3
|
|
|
|
#IE
|
|
ld 9,ie0@got@tprel(2) #R_PPC64_GOT_TPREL16_DS ie0
|
|
lhzx 10,9,ie0@tls #R_PPC64_TLS ie0
|
|
|
|
#LE
|
|
lbz 10,le0@tprel(13) #R_PPC64_TPREL16 le0
|
|
|
|
addis 9,13,le1@tprel@ha #R_PPC64_TPREL16_HA le1
|
|
stb 10,le1@tprel@l(9) #R_PPC64_TPREL16_LO le1
|
|
|
|
#local syms
|
|
#GD
|
|
addi 3,2,gd4@got@tlsgd #R_PPC64_GOT_TLSGD16 gd4
|
|
.ifdef TLSMARK
|
|
bl __tls_get_addr(gd4@tlsgd) #R_PPC64_TLSGD gd4
|
|
#R_PPC64_REL24 __tls_get_addr
|
|
.else
|
|
bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
|
|
.endif
|
|
nop
|
|
|
|
#LD
|
|
addi 3,2,ld4@got@tlsld #R_PPC64_GOT_TLSLD16 ld4
|
|
.ifdef TLSMARK
|
|
bl __tls_get_addr(ld4@tlsld) #R_PPC64_TLSLD ld4
|
|
#R_PPC64_REL24 __tls_get_addr
|
|
.else
|
|
bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
|
|
.endif
|
|
nop
|
|
|
|
std 10,ld4@dtprel(3) #R_PPC64_DTPREL16_DS ld4
|
|
|
|
addis 9,3,ld5@dtprel@ha #R_PPC64_DTPREL16_HA ld5
|
|
stw 10,ld5@dtprel@l(9) #R_PPC64_DTPREL16_LO ld5
|
|
|
|
ld 9,ld6@got@dtprel(2) #R_PPC64_GOT_DTPREL16_DS ld6
|
|
stdx 10,9,3
|
|
|
|
#IE
|
|
ld 9,ie0@got@tprel(2) #R_PPC64_GOT_TPREL16_DS ie4
|
|
sthx 10,9,ie0@tls #R_PPC64_TLS ie4
|
|
|
|
#LE
|
|
lwa 10,le4@tprel(13) #R_PPC64_TPREL16 le4
|
|
|
|
addis 9,13,le5@tprel@ha #R_PPC64_TPREL16_HA le5
|
|
lha 10,le5@tprel@l(9) #R_PPC64_TPREL16_LO le5
|