diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-02-10 18:58:00 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-02-10 18:58:00 +0000 |
commit | 2cef4257d02ec72a6ca3bef6ce189fe002253bf6 (patch) | |
tree | 964da6844fa5c3216edeb2f2e259bc57ccf468ea /elf/tls-macros.h | |
parent | a5176eabfb9cb8bc76b34dbce68c1ad3efbbc57e (diff) | |
download | glibc-2cef4257d02ec72a6ca3bef6ce189fe002253bf6.tar.gz |
Update.
* elf/tst-tls1.c: Move TLS helper macros to...
* elf/tls-macros.h: ...here. New file.
* elf/tst-tls2.c: New file.
* elf/Makefile (tests): Add tst-tls2.
(distribute): Add tls-macros.h.
Diffstat (limited to 'elf/tls-macros.h')
-rw-r--r-- | elf/tls-macros.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/elf/tls-macros.h b/elf/tls-macros.h new file mode 100644 index 0000000000..c3018b83b1 --- /dev/null +++ b/elf/tls-macros.h @@ -0,0 +1,66 @@ +/* Macros to support TLS testing in times of missing compiler support. */ + +#define COMMON_INT_DEF(x) \ + asm (".tls_common " #x ",4,4") + +/* XXX This definition will probably be machine specific, too. */ +#define VAR_INT_DEF(x) \ + asm (".section .tdata\n\t" \ + ".globl " #x "\n" \ + #x ":\t.long 0\n\t" \ + ".previous") + + + /* XXX Each architecture must have its own asm for now. */ +#ifdef __i386__ +# define TLS_LE(x) \ + ({ int *__l; \ + asm ("movl %%gs:0,%0\n\t" \ + "subl $" #x "@tpoff,%0" \ + : "=r" (__l)); \ + __l; }) + +#define TLS_IE(x) \ + ({ int *__l, __b; \ + asm ("call 1f\n\t" \ + ".subsection 1\n" \ + "1:\tmovl (%%esp), %%ebx\n\t" \ + "ret\n\t" \ + ".previous\n\t" \ + "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \ + "movl %%gs:0,%0\n\t" \ + "subl " #x "@gottpoff(%%ebx),%0" \ + : "=r" (__l), "=&b" (__b)); \ + __l; }) + +#define TLS_LD(x) \ + ({ int *__l, __b; \ + asm ("call 1f\n\t" \ + ".subsection 1\n" \ + "1:\tmovl (%%esp), %%ebx\n\t" \ + "ret\n\t" \ + ".previous\n\t" \ + "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \ + "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \ + "call ___tls_get_addr@plt\n\t" \ + "leal " #x "@dtpoff(%%eax), %%eax" \ + : "=a" (__l), "=&b" (__b)); \ + __l; }) + +#define TLS_GD(x) \ + ({ int *__l, __b; \ + asm ("call 1f\n\t" \ + ".subsection 1\n" \ + "1:\tmovl (%%esp), %%ebx\n\t" \ + "ret\n\t" \ + ".previous\n\t" \ + "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \ + "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \ + "call ___tls_get_addr@plt\n\t" \ + "nop" \ + : "=a" (__l), "=&b" (__b)); \ + __l; }) + +#else +# error "No support for this architecture so far." +#endif |