From 296178913c5dfbc2b35842fc16ed680ef51fd402 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 5 Apr 2015 17:05:57 -0400 Subject: nt32: initial commit of core port files. signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information. --- crt/nt32/Scrt1.c | 2 ++ crt/nt32/crt1.c | 33 +++++++++++++++++++++++++++++++++ crt/nt32/crtdev.c | 3 +++ crt/nt32/crte.s | 19 +++++++++++++++++++ crt/nt32/crti.s | 41 +++++++++++++++++++++++++++++++++++++++++ crt/nt32/crtn.s | 13 +++++++++++++ crt/nt32/crtposix.c | 3 +++ 7 files changed, 114 insertions(+) create mode 100644 crt/nt32/Scrt1.c create mode 100644 crt/nt32/crt1.c create mode 100644 crt/nt32/crtdev.c create mode 100644 crt/nt32/crte.s create mode 100644 crt/nt32/crti.s create mode 100644 crt/nt32/crtn.s create mode 100644 crt/nt32/crtposix.c (limited to 'crt') 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; -- cgit v1.2.3