summaryrefslogtreecommitdiffhomepage
path: root/crt
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-03-08 13:23:20 -0400
committermidipix <writeonce@midipix.org>2015-03-08 13:23:20 -0400
commit86062740f1e8eeb4c554055cf304dc1e0e87ea43 (patch)
tree35d8309221f4fd2050fefbc1b3b3957a1099ce8a /crt
parent41058bd82ed2ae880c463d61e5702aef07681bf0 (diff)
downloadmmglue-86062740f1e8eeb4c554055cf304dc1e0e87ea43.tar.bz2
mmglue-86062740f1e8eeb4c554055cf304dc1e0e87ea43.tar.xz
initial commit of core port files.
signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'crt')
-rw-r--r--crt/nt64/Scrt1.c2
-rw-r--r--crt/nt64/crt1.c33
-rw-r--r--crt/nt64/crtdev.c3
-rw-r--r--crt/nt64/crte.s19
-rw-r--r--crt/nt64/crti.s41
-rw-r--r--crt/nt64/crtn.s13
-rw-r--r--crt/nt64/crtposix.c3
7 files changed, 114 insertions, 0 deletions
diff --git a/crt/nt64/Scrt1.c b/crt/nt64/Scrt1.c
new file mode 100644
index 0000000..ff5789f
--- /dev/null
+++ b/crt/nt64/Scrt1.c
@@ -0,0 +1,2 @@
+#define LIBC_STATIC
+#include "crt1.c"
diff --git a/crt/nt64/crt1.c b/crt/nt64/crt1.c
new file mode 100644
index 0000000..6d22669
--- /dev/null
+++ b/crt/nt64/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/nt64/crtdev.c b/crt/nt64/crtdev.c
new file mode 100644
index 0000000..8aa80e6
--- /dev/null
+++ b/crt/nt64/crtdev.c
@@ -0,0 +1,3 @@
+#include "psxglue.h"
+
+const int __crtopt_ttydbg = __PSXOPT_TTYDBG;
diff --git a/crt/nt64/crte.s b/crt/nt64/crte.s
new file mode 100644
index 0000000..9753213
--- /dev/null
+++ b/crt/nt64/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
+ .quad dso_main_routine
+ .quad _so_entry_point
+ .quad _init
+ .quad _fini
diff --git a/crt/nt64/crti.s b/crt/nt64/crti.s
new file mode 100644
index 0000000..14fdd90
--- /dev/null
+++ b/crt/nt64/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 %rax,%rax
+ push %rax
+ push %rcx
+ push %rdx
+ nop
+ nop
+
+.section .fini
+ xor %rax,%rax
+ push %rax
+ push %rcx
+ push %rdx
+ 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/nt64/crtn.s b/crt/nt64/crtn.s
new file mode 100644
index 0000000..b2c7790
--- /dev/null
+++ b/crt/nt64/crtn.s
@@ -0,0 +1,13 @@
+.section .init
+ pop %rdx
+ pop %rcx
+ pop %r10
+ or %r10,%rax
+ ret
+
+.section .fini
+ pop %rdx
+ pop %rcx
+ pop %r10
+ or %r10,%rax
+ ret
diff --git a/crt/nt64/crtposix.c b/crt/nt64/crtposix.c
new file mode 100644
index 0000000..b8e5113
--- /dev/null
+++ b/crt/nt64/crtposix.c
@@ -0,0 +1,3 @@
+#include "psxglue.h"
+
+const int __crtopt_posix = __PSXOPT_POSIX;