diff options
-rw-r--r-- | arch/nt32/psxglue.h | 2 | ||||
-rw-r--r-- | arch/nt64/psxglue.h | 2 | ||||
-rw-r--r-- | src/env/nt32/__copy_tls.c | 30 | ||||
-rw-r--r-- | src/env/nt32/__reset_tls.c | 13 | ||||
-rw-r--r-- | src/env/nt32/__reset_tls.s | 0 | ||||
-rw-r--r-- | src/env/nt64/__copy_tls.c | 30 | ||||
-rw-r--r-- | src/env/nt64/__reset_tls.c | 13 | ||||
-rw-r--r-- | src/env/nt64/__reset_tls.s | 0 | ||||
-rw-r--r-- | src/ldso/nt32/dynlink.c | 27 | ||||
-rw-r--r-- | src/ldso/nt64/dynlink.c | 27 |
10 files changed, 88 insertions, 56 deletions
diff --git a/arch/nt32/psxglue.h b/arch/nt32/psxglue.h index db2a8ed..ad0e07b 100644 --- a/arch/nt32/psxglue.h +++ b/arch/nt32/psxglue.h @@ -14,7 +14,7 @@ struct __ldso_vtbl { void * (*dlopen) (const char * file, int mode, const char ** pathv, int * status); int (*dlclose) (void *p); char * (*dlerror) (void); - void (*reset_tls) (void); + void (*tlsreset) (void); }; struct __psx_vtbl { diff --git a/arch/nt64/psxglue.h b/arch/nt64/psxglue.h index db2a8ed..ad0e07b 100644 --- a/arch/nt64/psxglue.h +++ b/arch/nt64/psxglue.h @@ -14,7 +14,7 @@ struct __ldso_vtbl { void * (*dlopen) (const char * file, int mode, const char ** pathv, int * status); int (*dlclose) (void *p); char * (*dlerror) (void); - void (*reset_tls) (void); + void (*tlsreset) (void); }; struct __psx_vtbl { diff --git a/src/env/nt32/__copy_tls.c b/src/env/nt32/__copy_tls.c new file mode 100644 index 0000000..b96f4ed --- /dev/null +++ b/src/env/nt32/__copy_tls.c @@ -0,0 +1,30 @@ +#define _BSD_SOURCE + +#include <unistd.h> +#include "psxglue.h" +#include "pthread_impl.h" + +extern const struct __ldso_vtbl * __ldso_vtbl; +extern const struct __psx_vtbl * __psx_vtbl; + +void *__copy_tls(unsigned char * mem) +{ + /** + * this is always the simple case, since: + * emutls is based on PE named sections; and + * tls allocation and initialization are handled by clone(2) + **/ + + pthread_t td; + uintptr_t addr; + + addr = (uintptr_t)mem; + addr += 0xf; + addr |= 0xf; + addr ^= 0xf; + + td = (struct __pthread *)addr; + td->dtv = 0; + + return td; +} diff --git a/src/env/nt32/__reset_tls.c b/src/env/nt32/__reset_tls.c new file mode 100644 index 0000000..7b6b6a5 --- /dev/null +++ b/src/env/nt32/__reset_tls.c @@ -0,0 +1,13 @@ +#define _BSD_SOURCE + +#include <unistd.h> +#include "psxglue.h" +#include "pthread_impl.h" + +extern const struct __ldso_vtbl * __ldso_vtbl; +extern const struct __psx_vtbl * __psx_vtbl; + +void __reset_tls(void) +{ + __ldso_vtbl->tlsreset(); +} diff --git a/src/env/nt32/__reset_tls.s b/src/env/nt32/__reset_tls.s deleted file mode 100644 index e69de29..0000000 --- a/src/env/nt32/__reset_tls.s +++ /dev/null diff --git a/src/env/nt64/__copy_tls.c b/src/env/nt64/__copy_tls.c new file mode 100644 index 0000000..b96f4ed --- /dev/null +++ b/src/env/nt64/__copy_tls.c @@ -0,0 +1,30 @@ +#define _BSD_SOURCE + +#include <unistd.h> +#include "psxglue.h" +#include "pthread_impl.h" + +extern const struct __ldso_vtbl * __ldso_vtbl; +extern const struct __psx_vtbl * __psx_vtbl; + +void *__copy_tls(unsigned char * mem) +{ + /** + * this is always the simple case, since: + * emutls is based on PE named sections; and + * tls allocation and initialization are handled by clone(2) + **/ + + pthread_t td; + uintptr_t addr; + + addr = (uintptr_t)mem; + addr += 0xf; + addr |= 0xf; + addr ^= 0xf; + + td = (struct __pthread *)addr; + td->dtv = 0; + + return td; +} diff --git a/src/env/nt64/__reset_tls.c b/src/env/nt64/__reset_tls.c new file mode 100644 index 0000000..7b6b6a5 --- /dev/null +++ b/src/env/nt64/__reset_tls.c @@ -0,0 +1,13 @@ +#define _BSD_SOURCE + +#include <unistd.h> +#include "psxglue.h" +#include "pthread_impl.h" + +extern const struct __ldso_vtbl * __ldso_vtbl; +extern const struct __psx_vtbl * __psx_vtbl; + +void __reset_tls(void) +{ + __ldso_vtbl->tlsreset(); +} diff --git a/src/env/nt64/__reset_tls.s b/src/env/nt64/__reset_tls.s deleted file mode 100644 index e69de29..0000000 --- a/src/env/nt64/__reset_tls.s +++ /dev/null diff --git a/src/ldso/nt32/dynlink.c b/src/ldso/nt32/dynlink.c index 6a4f4df..a585fbb 100644 --- a/src/ldso/nt32/dynlink.c +++ b/src/ldso/nt32/dynlink.c @@ -131,33 +131,6 @@ char * dlerror(void) return __ldso_vtbl->dlerror(); } -void __reset_tls(void) -{ - __ldso_vtbl->reset_tls(); -} - -void *__copy_tls(unsigned char * mem) -{ - /** - * this is always the simple case, since: - * emutls is based on PE named sections; and - * tls allocation and initialization are handled by clone(2) - **/ - - pthread_t td; - uintptr_t addr; - - addr = (uintptr_t)mem; - addr >>= 4; - addr <<= 4; - addr += 16; - - td = (struct __pthread *)addr; - td->dtv = 0; - - return td; -} - weak_alias(__dlsym,dlsym); weak_alias(__dladdr,dladdr); weak_alias(__dlinfo,dlinfo); diff --git a/src/ldso/nt64/dynlink.c b/src/ldso/nt64/dynlink.c index 6a4f4df..a585fbb 100644 --- a/src/ldso/nt64/dynlink.c +++ b/src/ldso/nt64/dynlink.c @@ -131,33 +131,6 @@ char * dlerror(void) return __ldso_vtbl->dlerror(); } -void __reset_tls(void) -{ - __ldso_vtbl->reset_tls(); -} - -void *__copy_tls(unsigned char * mem) -{ - /** - * this is always the simple case, since: - * emutls is based on PE named sections; and - * tls allocation and initialization are handled by clone(2) - **/ - - pthread_t td; - uintptr_t addr; - - addr = (uintptr_t)mem; - addr >>= 4; - addr <<= 4; - addr += 16; - - td = (struct __pthread *)addr; - td->dtv = 0; - - return td; -} - weak_alias(__dlsym,dlsym); weak_alias(__dladdr,dladdr); weak_alias(__dlinfo,dlinfo); |