Revert "Use %gs as TLS register when dlopen() is linked"

This reverts commit d71da7fc72.
This commit is contained in:
Justine Tunney 2023-11-08 01:33:01 -08:00
parent d71da7fc72
commit 956e68be59
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
13 changed files with 40 additions and 71 deletions

View file

@ -26,9 +26,6 @@
#include "libc/thread/tls.h"
#include "libc/thread/tls2.internal.h"
#define AMD64_SET_FSBASE 129
#define AMD64_SET_GSBASE 131
int sys_set_tls();
textstartup void __set_tls(struct CosmoTib *tib) {
@ -39,9 +36,9 @@ textstartup void __set_tls(struct CosmoTib *tib) {
npassert(0 <= __tls_index && __tls_index < 64);
asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tib));
} else if (IsFreebsd()) {
sys_set_tls(__tls_morphed ? AMD64_SET_GSBASE : AMD64_SET_FSBASE, tib);
sys_set_tls(129 /*AMD64_SET_FSBASE*/, tib);
} else if (IsLinux()) {
sys_set_tls(__tls_morphed ? ARCH_SET_GS : ARCH_SET_FS, tib);
sys_set_tls(ARCH_SET_FS, tib);
} else if (IsNetbsd()) {
// netbsd has sysarch(X86_SET_FSBASE) but we can't use that because
// signal handlers will cause it to be reset due to not setting the