mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
ad961eab9a
There are extensions to x86-64 psABI: https://groups.google.com/forum/#!topic/x86-64-abi/de5_KnLHxtI to call tls_get_addr via GOT: call *__tls_get_addr@GOTPCREL(%rip) Since direct call is 4-byte long and indirect call, is 5-byte long, the extra one byte must be handled properly. For general dynamic model, one 0x66 prefix before call instruction is removed to make room for indirect call. For local dynamic model, we simply use 5-byte indirect call. TLS linker optimization is updated to recognize new instruction patterns. For local dynamic model to local exec model transition, we generate 4 0x66 prefixes, instead of 3, before mov instruction in 64-bit and generate a 5-byte nop, instead of 4-byte, before mov instruction in 32-bit. PR gold/20216 * configure.ac (DEFAULT_TARGET_X86_64_OR_X32): New AM_CONDITIONAL. * configure: Regenerated. * x86_64.cc (Target_x86_64<size>::Relocate::relocate): Allow R_X86_64_GOTPCRELX relocation against __tls_get_addr. (Target_x86_64<size>::Relocate::tls_gd_to_ie): Support indirect call to __tls_get_addr. (Target_x86_64<size>::Relocate::tls_gd_to_le): Likewise. (Target_x86_64<size>::Relocate::tls_ld_to_le): Likewise. * testsuite/Makefile.am (check_PROGRAMS): Add pr20216a_test, pr20216b_test, pr20216c_test, pr20216d_test, pr20216e_test. (pr20216a_test_SOURCES): New. (pr20216a_test_DEPENDENCIES): Likewise. (pr20216a_test_CFLAGS): Likewise. (pr20216a_test_LDFLAGS): Likewise. (pr20216a_test_LDADD): Likewise. (pr20216b_test_SOURCES): Likewise. (pr20216b_test_DEPENDENCIES): Likewise. (pr20216b_test_CFLAGS): Likewise. (pr20216b_test_LDFLAGS): Likewise. (pr20216b_test_LDADD): Likewise. (pr20216c_test_SOURCES): Likewise. (pr20216c_test_DEPENDENCIES): Likewise. (pr20216c_test_CFLAGS): Likewise. (pr20216c_test_LDFLAGS): Likewise. (pr20216c_test_LDADD): Likewise. (pr20216d_test_SOURCES): Likewise. (pr20216d_test_DEPENDENCIES): Likewise. (pr20216d_test_CFLAGS): Likewise. (pr20216d_test_LDFLAGS): Likewise. (pr20216d_test_LDADD): Likewise. (pr20216e_test_SOURCES): Likewise. (pr20216e_test_DEPENDENCIES): Likewise. (pr20216e_test_CFLAGS): Likewise. (pr20216e_test_LDFLAGS): Likewise. (pr20216e_test_LDADD): Likewise. (pr20216a.so): Likewise. (pr20216b.so): Likewise. (pr20216_gd.o): Likewise. (pr20216_ld.o): Likewise. (MOSTLYCLEANFILES): Add pr20216a.so pr20216b.so. * testsuite/Makefile.in: Regenerated. * testsuite/pr20216_def.c: New file. * testsuite/pr20216_gd.S: Likewise. * testsuite/pr20216_ld.S: Likewise. * testsuite/pr20216_main.c: Likewise.
48 lines
826 B
ArmAsm
48 lines
826 B
ArmAsm
.text
|
|
.p2align 4,,15
|
|
.globl get_ld
|
|
.type get_ld, @function
|
|
get_ld:
|
|
subq $8, %rsp
|
|
leaq ld@tlsld(%rip), %rdi
|
|
call __tls_get_addr@PLT
|
|
addq $8, %rsp
|
|
addq $ld@dtpoff, %rax
|
|
ret
|
|
.size get_ld, .-get_ld
|
|
.text
|
|
.p2align 4,,15
|
|
.globl set_ld
|
|
.type set_ld, @function
|
|
set_ld:
|
|
pushq %rbx
|
|
movl %edi, %ebx
|
|
leaq ld@tlsld(%rip), %rdi
|
|
call *__tls_get_addr@GOTPCREL(%rip)
|
|
movl %ebx, ld@dtpoff(%rax)
|
|
popq %rbx
|
|
ret
|
|
.size set_ld, .-set_ld
|
|
.text
|
|
.p2align 4,,15
|
|
.globl test_ld
|
|
.type test_ld, @function
|
|
test_ld:
|
|
pushq %rbx
|
|
movl %edi, %ebx
|
|
leaq ld@tlsld(%rip), %rdi
|
|
call *__tls_get_addr@GOTPCREL(%rip)
|
|
cmpl %ebx, ld@dtpoff(%rax)
|
|
popq %rbx
|
|
sete %al
|
|
movzbl %al, %eax
|
|
ret
|
|
.size test_ld, .-test_ld
|
|
.section .tbss,"awT",@nobits
|
|
.align 4
|
|
.type ld, @object
|
|
.size ld, 4
|
|
ld:
|
|
.zero 4
|
|
.section .note.GNU-stack,"",@progbits
|