diff options
author | midipix <writeonce@midipix.org> | 2016-09-17 23:23:23 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-09-17 23:25:09 -0400 |
commit | 4a46973f96b93f8f24c8bb8d0a2f7a168f83150a (patch) | |
tree | 4675144e2187d2e627007debac18361408db12b8 /arch/nt32 | |
parent | dd08487036d1e8ef81260c46c6bfb76be45f7b4b (diff) | |
download | mmglue-4a46973f96b93f8f24c8bb8d0a2f7a168f83150a.tar.bz2 mmglue-4a46973f96b93f8f24c8bb8d0a2f7a168f83150a.tar.xz |
nt32: fix ctor/dtor logic, match nt64 and libpsxscl.
Diffstat (limited to 'arch/nt32')
-rw-r--r-- | arch/nt32/src/crt_glue.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/arch/nt32/src/crt_glue.c b/arch/nt32/src/crt_glue.c index b92db1a..7c7d8b2 100644 --- a/arch/nt32/src/crt_glue.c +++ b/arch/nt32/src/crt_glue.c @@ -8,13 +8,9 @@ extern struct __ldso_vtbl * __ldso_vtbl; extern struct __psx_vtbl * __psx_vtbl; -extern void * __init_array_start[]; -extern void * __fini_array_start[]; - typedef int __app_main(); typedef int __pthread_surrogate_routine(struct pthread *); -extern int _init(void); static int __pthread_surrogate_init(struct pthread * self); extern int __libc_start_main( @@ -22,7 +18,20 @@ extern int __libc_start_main( int argc, char ** argv); -static struct __tls { +static void (*__global_ctors_fn)(); +static void (*__global_dtors_fn)(); + +void _init() +{ + __global_ctors_fn(); +} + +void _fini() +{ + __global_dtors_fn(); +} + +struct __tls { void * pad[16/sizeof(void *)]; struct pthread pt; } __builtin_tls = {{0}}; @@ -73,8 +82,8 @@ void __libc_entry_routine( __teb_libc_idx = ctx.teb_libc_idx; /* surrogate init/fini arrays */ - *__init_array_start = ctx.do_global_ctors_fn; - *__fini_array_start = ctx.do_global_dtors_fn; + __global_ctors_fn = ctx.do_global_ctors_fn; + __global_dtors_fn = ctx.do_global_dtors_fn; /* enter libc */ __libc_start_main(__main,argc,argv); |