tls-macros-x86_64.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #define TLS_LE(x) \
  2. ({ int *__l; \
  3. __asm__ ("mov %%fs:0,%0\n\t" \
  4. "lea " #x "@tpoff(%0), %0" \
  5. : "=r" (__l)); \
  6. __l; })
  7. #define TLS_IE(x) \
  8. ({ int *__l; \
  9. __asm__ ("mov %%fs:0,%0\n\t" \
  10. "add " #x "@gottpoff(%%rip),%0" \
  11. : "=r" (__l)); \
  12. __l; })
  13. #define TLS_LD(x) \
  14. ({ int *__l, __c, __d; \
  15. __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
  16. "call __tls_get_addr@plt\n\t" \
  17. "leaq " #x "@dtpoff(%%rax), %%rax" \
  18. : "=a" (__l), "=&c" (__c), "=&d" (__d) \
  19. : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
  20. __l; })
  21. #ifdef __ILP32__
  22. # define TLS_GD_PREFIX
  23. #else
  24. # define TLS_GD_PREFIX ".byte 0x66\n\t"
  25. #endif
  26. #define TLS_GD(x) \
  27. ({ int *__l, __c, __d; \
  28. __asm__ (TLS_GD_PREFIX \
  29. "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
  30. ".word 0x6666\n\t" \
  31. "rex64\n\t" \
  32. "call __tls_get_addr@plt" \
  33. : "=a" (__l), "=&c" (__c), "=&d" (__d) \
  34. : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
  35. __l; })