tls-macros-i386.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #define TLS_LE(x) \
  2. ({ int *__l; \
  3. __asm__ ("movl %%gs:0,%0\n\t" \
  4. "subl $" #x "@tpoff,%0" \
  5. : "=r" (__l)); \
  6. __l; })
  7. #ifdef __PIC__
  8. # define TLS_IE(x) \
  9. ({ int *__l; \
  10. __asm__ ("movl %%gs:0,%0\n\t" \
  11. "subl " #x "@gottpoff(%%ebx),%0" \
  12. : "=r" (__l)); \
  13. __l; })
  14. #else
  15. # define TLS_IE(x) \
  16. ({ int *__l; \
  17. __asm__ ("call 1f\n\t" \
  18. ".subsection 1\n" \
  19. "1:\tmovl (%%esp), %%ebx\n\t" \
  20. "ret\n\t" \
  21. ".previous\n\t" \
  22. "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
  23. "movl %%gs:0,%0\n\t" \
  24. "subl " #x "@gottpoff(%%ebx),%0" \
  25. : "=r" (__l)); \
  26. __l; })
  27. #endif
  28. #ifdef __PIC__
  29. # define TLS_LD(x) \
  30. ({ int *__l, __c, __d; \
  31. __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
  32. "call ___tls_get_addr@plt\n\t" \
  33. "leal " #x "@dtpoff(%%eax), %%eax" \
  34. : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
  35. __l; })
  36. #else
  37. # define TLS_LD(x) \
  38. ({ int *__l, __b, __c, __d; \
  39. __asm__ ("call 1f\n\t" \
  40. ".subsection 1\n" \
  41. "1:\tmovl (%%esp), %%ebx\n\t" \
  42. "ret\n\t" \
  43. ".previous\n\t" \
  44. "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
  45. "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
  46. "call ___tls_get_addr@plt\n\t" \
  47. "leal " #x "@dtpoff(%%eax), %%eax" \
  48. : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
  49. __l; })
  50. #endif
  51. #ifdef __PIC__
  52. # define TLS_GD(x) \
  53. ({ int *__l, __c, __d; \
  54. __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
  55. "call ___tls_get_addr@plt\n\t" \
  56. "nop" \
  57. : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
  58. __l; })
  59. #else
  60. # define TLS_GD(x) \
  61. ({ int *__l, __c, __d; \
  62. __asm__ ("call 1f\n\t" \
  63. ".subsection 1\n" \
  64. "1:\tmovl (%%esp), %%ebx\n\t" \
  65. "ret\n\t" \
  66. ".previous\n\t" \
  67. "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
  68. "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
  69. "call ___tls_get_addr@plt\n\t" \
  70. "nop" \
  71. : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
  72. __l; })
  73. #endif