diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-22 22:34:31 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-22 22:34:31 +0200 |
commit | af6b1cce9812273c7f597be6536d28eaec6fb89b (patch) | |
tree | a4e6e3eaa478ec9435a4669fed252a543dc466ab /sysdeps/mach/hurd/i386/tls.h | |
parent | 4565083abc972bffe810e4151f8f3cb48531e526 (diff) | |
download | glibc-af6b1cce9812273c7f597be6536d28eaec6fb89b.tar.gz glibc-af6b1cce9812273c7f597be6536d28eaec6fb89b.tar.xz glibc-af6b1cce9812273c7f597be6536d28eaec6fb89b.zip |
hurd: Fix starting static binaries with stack protection enabled
gcc introduces gs:0x14 accesses in most functions, so we need some tcbhead to be ready very early during initialization. This configures a static area which can be referenced by various protected functions, until proper TLS is set up.
Diffstat (limited to 'sysdeps/mach/hurd/i386/tls.h')
-rw-r--r-- | sysdeps/mach/hurd/i386/tls.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index 264ed9a9c5..3817b7230d 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -49,7 +49,6 @@ typedef struct mach_port_t reply_port; /* This thread's reply port. */ struct hurd_sigstate *_hurd_sigstate; } tcbhead_t; -#endif /* Return tcbhead_t from a TLS segment descriptor. */ # define HURD_DESC_TLS(desc) \ @@ -60,10 +59,18 @@ typedef struct }) /* Return 1 if TLS is not initialized yet. */ +#ifndef SHARED +extern unsigned short __init1_desc; +#define __HURD_DESC_INITIAL(gs, ds) ((gs) == (ds) || (gs) == __init1_desc) +#else +#define __HURD_DESC_INITIAL(gs, ds) ((gs) == (ds)) +#endif + #define __LIBC_NO_TLS() \ ({ unsigned short ds, gs; \ asm ("movw %%ds,%w0; movw %%gs,%w1" : "=q" (ds), "=q" (gs)); \ - __builtin_expect (ds == gs, 0); }) + __builtin_expect(__HURD_DESC_INITIAL(gs, ds), 0); }) +#endif /* The TCB can have any size and the memory following the address the thread pointer points to is unspecified. Allocate the TCB there. */ |