From ad961eab9a010e79d17a4ea7e6bb977fe6dd86c2 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 29 Jun 2016 08:37:30 -0700 Subject: gold: Support x86-64 TLS code sequences without PLT 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::Relocate::relocate): Allow R_X86_64_GOTPCRELX relocation against __tls_get_addr. (Target_x86_64::Relocate::tls_gd_to_ie): Support indirect call to __tls_get_addr. (Target_x86_64::Relocate::tls_gd_to_le): Likewise. (Target_x86_64::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. --- gold/configure.ac | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gold/configure.ac') diff --git a/gold/configure.ac b/gold/configure.ac index 90e2c22..de3b630 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -237,6 +237,8 @@ for targ in $target $canon_targets; do fi AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$target_x86_64" = "yes") AM_CONDITIONAL(DEFAULT_TARGET_X32, test "$target_x32" = "yes") + AM_CONDITIONAL(DEFAULT_TARGET_X86_64_OR_X32, + test "$target_x86_64" = "yes" -o "$target_x32" = "yes") AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx") AM_CONDITIONAL(DEFAULT_TARGET_MIPS, test "$targ_obj" = "mips") DEFAULT_TARGET=${targ_obj} -- cgit v1.1