summaryrefslogtreecommitdiffhomepage
path: root/crt
diff options
context:
space:
mode:
Diffstat (limited to 'crt')
-rw-r--r--crt/nt32/Scrt1.c2
-rw-r--r--crt/nt32/crt1.c33
-rw-r--r--crt/nt32/crtdev.c3
-rw-r--r--crt/nt32/crte.s19
-rw-r--r--crt/nt32/crti.s41
-rw-r--r--crt/nt32/crtn.s13
-rw-r--r--crt/nt32/crtposix.c3
7 files changed, 114 insertions, 0 deletions
diff --git a/crt/nt32/Scrt1.c b/crt/nt32/Scrt1.c
new file mode 100644
index 0000000..ff5789f
--- /dev/null
+++ b/crt/nt32/Scrt1.c
@@ -0,0 +1,2 @@
+#define LIBC_STATIC
+#include "crt1.c"
diff --git a/crt/nt32/crt1.c b/crt/nt32/crt1.c
new file mode 100644
index 0000000..6d22669
--- /dev/null
+++ b/crt/nt32/crt1.c
@@ -0,0 +1,33 @@
+#ifdef LIBC_STATIC
+#define __external_routine
+#else
+#define __external_routine __attribute__((dllimport))
+#endif
+
+#include "psxglue.h"
+
+/**
+ * options: posix session, fallback terminal emulator
+ * x86_64-nt64-midipix-gcc --target-help | grep -A2 posix
+**/
+
+static const int __disabled = 0;
+extern const int __crtopt_posix __attribute((weak,alias("__disabled")));
+extern const int __crtopt_ttydbg __attribute((weak,alias("__disabled")));
+
+int main();
+
+__external_routine
+__psx_init_routine __psx_init;
+
+__external_routine
+void __libc_entry_routine(void *,void *,int);
+
+void _start(void)
+{
+ __libc_entry_routine(
+ main,
+ __psx_init,
+ __crtopt_posix | __crtopt_ttydbg);
+}
+
diff --git a/crt/nt32/crtdev.c b/crt/nt32/crtdev.c
new file mode 100644
index 0000000..8aa80e6
--- /dev/null
+++ b/crt/nt32/crtdev.c
@@ -0,0 +1,3 @@
+#include "psxglue.h"
+
+const int __crtopt_ttydbg = __PSXOPT_TTYDBG;
diff --git a/crt/nt32/crte.s b/crt/nt32/crte.s
new file mode 100644
index 0000000..56fa138
--- /dev/null
+++ b/crt/nt32/crte.s
@@ -0,0 +1,19 @@
+.text
+.globl __so_entry_point
+__so_entry_point:
+ cmp $0x1,%edx
+ jne _dso_main_routine
+ mov %edx,%eax
+ ret
+
+___dso_main_routine:
+ ret
+
+ .weak _dso_main_routine
+ .set _dso_main_routine,___dso_main_routine
+
+.section .midipix
+ .long _dso_main_routine
+ .long __so_entry_point
+ .long __init
+ .long __fini
diff --git a/crt/nt32/crti.s b/crt/nt32/crti.s
new file mode 100644
index 0000000..7b1a642
--- /dev/null
+++ b/crt/nt32/crti.s
@@ -0,0 +1,41 @@
+.text
+.globl __pei386_runtime_relocator
+__pei386_runtime_relocator:
+ ret
+
+.globl __init
+__init:
+ call .init
+ ret
+
+.globl __fini
+__fini:
+ call .fini
+ ret
+
+.section .init
+ xor %eax,%eax
+ push %eax
+ push %ecx
+ push %edx
+ nop
+ nop
+
+.section .fini
+ xor %eax,%eax
+ push %eax
+ push %ecx
+ push %edx
+ nop
+ nop
+
+.section .midipix
+ .ascii "e35ed272"
+ .ascii "9e55"
+ .ascii "46c1"
+ .ascii "8251"
+ .ascii "022a59e6c480"
+ .long 0
+ .long 1
+ .long 0
+ .long 0
diff --git a/crt/nt32/crtn.s b/crt/nt32/crtn.s
new file mode 100644
index 0000000..2d0295e
--- /dev/null
+++ b/crt/nt32/crtn.s
@@ -0,0 +1,13 @@
+.section .init
+ pop %edx
+ pop %ecx
+ pop %ebx
+ or %ebx,%eax
+ ret
+
+.section .fini
+ pop %edx
+ pop %ecx
+ pop %ebx
+ or %ebx,%eax
+ ret
diff --git a/crt/nt32/crtposix.c b/crt/nt32/crtposix.c
new file mode 100644
index 0000000..b8e5113
--- /dev/null
+++ b/crt/nt32/crtposix.c
@@ -0,0 +1,3 @@
+#include "psxglue.h"
+
+const int __crtopt_posix = __PSXOPT_POSIX;