lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #include <features.h> /* For __GNUC_PREREQ. */ |
| 2 | |
| 3 | #define TLS_LE(x) \ |
| 4 | ({ int *__l; \ |
| 5 | asm ("movl %%gs:0,%0\n\t" \ |
| 6 | "subl $" #x "@tpoff,%0" \ |
| 7 | : "=r" (__l)); \ |
| 8 | __l; }) |
| 9 | |
| 10 | #if defined PIC && !__GNUC_PREREQ (5,0) |
| 11 | # define TLS_IE(x) \ |
| 12 | ({ int *__l; \ |
| 13 | asm ("movl %%gs:0,%0\n\t" \ |
| 14 | "subl " #x "@gottpoff(%%ebx),%0" \ |
| 15 | : "=r" (__l)); \ |
| 16 | __l; }) |
| 17 | #else |
| 18 | # define TLS_IE(x) \ |
| 19 | ({ int *__l, __b; \ |
| 20 | asm ("call 1f\n\t" \ |
| 21 | ".subsection 1\n" \ |
| 22 | "1:\tmovl (%%esp), %%ebx\n\t" \ |
| 23 | "ret\n\t" \ |
| 24 | ".previous\n\t" \ |
| 25 | "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \ |
| 26 | "movl %%gs:0,%0\n\t" \ |
| 27 | "subl " #x "@gottpoff(%%ebx),%0" \ |
| 28 | : "=r" (__l), "=&b" (__b)); \ |
| 29 | __l; }) |
| 30 | #endif |
| 31 | |
| 32 | #if defined PIC && !__GNUC_PREREQ (5,0) |
| 33 | # define TLS_LD(x) \ |
| 34 | ({ int *__l, __c, __d; \ |
| 35 | asm ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \ |
| 36 | "call ___tls_get_addr@plt\n\t" \ |
| 37 | "leal " #x "@dtpoff(%%eax), %%eax" \ |
| 38 | : "=a" (__l), "=&c" (__c), "=&d" (__d)); \ |
| 39 | __l; }) |
| 40 | #else |
| 41 | # define TLS_LD(x) \ |
| 42 | ({ int *__l, __b, __c, __d; \ |
| 43 | asm ("call 1f\n\t" \ |
| 44 | ".subsection 1\n" \ |
| 45 | "1:\tmovl (%%esp), %%ebx\n\t" \ |
| 46 | "ret\n\t" \ |
| 47 | ".previous\n\t" \ |
| 48 | "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \ |
| 49 | "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \ |
| 50 | "call ___tls_get_addr@plt\n\t" \ |
| 51 | "leal " #x "@dtpoff(%%eax), %%eax" \ |
| 52 | : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \ |
| 53 | __l; }) |
| 54 | #endif |
| 55 | |
| 56 | #if defined PIC && !__GNUC_PREREQ (5,0) |
| 57 | # define TLS_GD(x) \ |
| 58 | ({ int *__l, __c, __d; \ |
| 59 | asm ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \ |
| 60 | "call ___tls_get_addr@plt\n\t" \ |
| 61 | "nop" \ |
| 62 | : "=a" (__l), "=&c" (__c), "=&d" (__d)); \ |
| 63 | __l; }) |
| 64 | #else |
| 65 | # define TLS_GD(x) \ |
| 66 | ({ int *__l, __b, __c, __d; \ |
| 67 | asm ("call 1f\n\t" \ |
| 68 | ".subsection 1\n" \ |
| 69 | "1:\tmovl (%%esp), %%ebx\n\t" \ |
| 70 | "ret\n\t" \ |
| 71 | ".previous\n\t" \ |
| 72 | "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \ |
| 73 | "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \ |
| 74 | "call ___tls_get_addr@plt\n\t" \ |
| 75 | "nop" \ |
| 76 | : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \ |
| 77 | __l; }) |
| 78 | #endif |