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.
56 lines
865 B
ArmAsm
56 lines
865 B
ArmAsm
.text
|
|
.p2align 4,,15
|
|
.globl get_gd
|
|
.type get_gd, @function
|
|
get_gd:
|
|
subq $8, %rsp
|
|
#ifdef __LP64__
|
|
.byte 0x66
|
|
#endif
|
|
leaq gd@tlsgd(%rip), %rdi
|
|
.byte 0x66
|
|
rex64
|
|
call *__tls_get_addr@GOTPCREL(%rip)
|
|
addq $8, %rsp
|
|
ret
|
|
.size get_gd, .-get_gd
|
|
.text
|
|
.p2align 4,,15
|
|
.globl set_gd
|
|
.type set_gd, @function
|
|
set_gd:
|
|
pushq %rbx
|
|
movl %edi, %ebx
|
|
#ifdef __LP64__
|
|
.byte 0x66
|
|
#endif
|
|
leaq gd@tlsgd(%rip), %rdi
|
|
.value 0x6666
|
|
rex64
|
|
call __tls_get_addr@PLT
|
|
movl %ebx, (%rax)
|
|
popq %rbx
|
|
ret
|
|
.size set_gd, .-set_gd
|
|
.text
|
|
.p2align 4,,15
|
|
.globl test_gd
|
|
.type test_gd, @function
|
|
test_gd:
|
|
pushq %rbx
|
|
movl %edi, %ebx
|
|
#ifdef __LP64__
|
|
.byte 0x66
|
|
#endif
|
|
leaq gd@tlsgd(%rip), %rdi
|
|
.byte 0x66
|
|
rex64
|
|
call *__tls_get_addr@GOTPCREL(%rip)
|
|
cmpl %ebx, (%rax)
|
|
popq %rbx
|
|
sete %al
|
|
movzbl %al, %eax
|
|
ret
|
|
.size test_gd, .-test_gd
|
|
.section .note.GNU-stack,"",@progbits
|