summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-04-25 10:14:19 -0400
committermidipix <writeonce@midipix.org>2015-04-25 10:14:19 -0400
commit5085e91a323072e923f46bad4199e6abd9d12ae7 (patch)
tree1d007a1140fb6049186e0749a41f615060e834ab /src
parent0f5685a2ffe65b6c6154f5500a26983852eaf1f3 (diff)
downloadmmglue-5085e91a323072e923f46bad4199e6abd9d12ae7.tar.bz2
mmglue-5085e91a323072e923f46bad4199e6abd9d12ae7.tar.xz
complete/fix support of ctors/dtors and tls.
+ do not build libc.so with -DSHARED for the midipix targets. + provide surrogate init/fini arrays that allow invocation of the ctors/dtors iteration routines. + provide a builtin tls for the first thread. + update __copy_tls to match the layout of the simplified struct __tls. signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'src')
-rw-r--r--src/env/nt32/__init_tls.s0
-rw-r--r--src/env/nt32/__reset_tls.s0
-rw-r--r--src/env/nt64/__init_tls.s0
-rw-r--r--src/env/nt64/__reset_tls.s0
-rw-r--r--src/ldso/nt32/dynlink.c12
-rw-r--r--src/ldso/nt32/start.s19
-rw-r--r--src/ldso/nt64/dynlink.c12
-rw-r--r--src/ldso/nt64/start.s19
8 files changed, 52 insertions, 10 deletions
diff --git a/src/env/nt32/__init_tls.s b/src/env/nt32/__init_tls.s
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/env/nt32/__init_tls.s
diff --git a/src/env/nt32/__reset_tls.s b/src/env/nt32/__reset_tls.s
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/env/nt32/__reset_tls.s
diff --git a/src/env/nt64/__init_tls.s b/src/env/nt64/__init_tls.s
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/env/nt64/__init_tls.s
diff --git a/src/env/nt64/__reset_tls.s b/src/env/nt64/__reset_tls.s
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/env/nt64/__reset_tls.s
diff --git a/src/ldso/nt32/dynlink.c b/src/ldso/nt32/dynlink.c
index c3cb23e..edfa4a8 100644
--- a/src/ldso/nt32/dynlink.c
+++ b/src/ldso/nt32/dynlink.c
@@ -50,13 +50,15 @@ void *__copy_tls(unsigned char * mem)
**/
pthread_t td;
- void ** dtv;
+ uintptr_t addr;
- dtv = (void **)mem;
- dtv[0] = 0;
+ addr = (uintptr_t)mem;
+ addr >>= 4;
+ addr <<= 4;
+ addr += 16;
- td = (void *)(dtv + 1);
- td->dtv = dtv;
+ td = (struct __pthread *)addr;
+ td->dtv = 0;
return td;
}
diff --git a/src/ldso/nt32/start.s b/src/ldso/nt32/start.s
index 32dc52f..d4815dd 100644
--- a/src/ldso/nt32/start.s
+++ b/src/ldso/nt32/start.s
@@ -1,2 +1,21 @@
# standard dynamic loader is not required
# optional dynamic loader [to be] provided by libldso/libpsxscl
+
+.section .data
+
+.globl ___init_array_start
+.globl ___init_array_end
+.globl ___fini_array_start
+.globl ___fini_array_end
+
+___init_array_start:
+ .long 0
+
+___init_array_end:
+ .long 0
+
+___fini_array_start:
+ .long 0
+
+___fini_array_end:
+ .long 0
diff --git a/src/ldso/nt64/dynlink.c b/src/ldso/nt64/dynlink.c
index c3cb23e..edfa4a8 100644
--- a/src/ldso/nt64/dynlink.c
+++ b/src/ldso/nt64/dynlink.c
@@ -50,13 +50,15 @@ void *__copy_tls(unsigned char * mem)
**/
pthread_t td;
- void ** dtv;
+ uintptr_t addr;
- dtv = (void **)mem;
- dtv[0] = 0;
+ addr = (uintptr_t)mem;
+ addr >>= 4;
+ addr <<= 4;
+ addr += 16;
- td = (void *)(dtv + 1);
- td->dtv = dtv;
+ td = (struct __pthread *)addr;
+ td->dtv = 0;
return td;
}
diff --git a/src/ldso/nt64/start.s b/src/ldso/nt64/start.s
index 32dc52f..e710319 100644
--- a/src/ldso/nt64/start.s
+++ b/src/ldso/nt64/start.s
@@ -1,2 +1,21 @@
# standard dynamic loader is not required
# optional dynamic loader [to be] provided by libldso/libpsxscl
+
+.section .data
+
+.globl __init_array_start
+.globl __init_array_end
+.globl __fini_array_start
+.globl __fini_array_end
+
+__init_array_start:
+ .quad 0
+
+__init_array_end:
+ .quad 0
+
+__fini_array_start:
+ .quad 0
+
+__fini_array_end:
+ .quad 0