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