diff options
Diffstat (limited to 'src/user/runtimes')
-rw-r--r-- | src/user/runtimes/asm/elf.ld | 8 | ||||
-rw-r--r-- | src/user/runtimes/c/elf.ld | 22 | ||||
-rw-r--r-- | src/user/runtimes/c/entry.asm | 42 |
3 files changed, 72 insertions, 0 deletions
diff --git a/src/user/runtimes/asm/elf.ld b/src/user/runtimes/asm/elf.ld new file mode 100644 index 0000000..aaef517 --- /dev/null +++ b/src/user/runtimes/asm/elf.ld @@ -0,0 +1,8 @@ +OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) +ENTRY(_entry) + +MEMORY { + kernel (!a) : ORIGIN = 0x00000000, LENGTH = 0x08000000 + user (awx) : ORIGIN = 0x08000000, LENGTH = 0xf8000000 +}
\ No newline at end of file diff --git a/src/user/runtimes/c/elf.ld b/src/user/runtimes/c/elf.ld new file mode 100644 index 0000000..f321be2 --- /dev/null +++ b/src/user/runtimes/c/elf.ld @@ -0,0 +1,22 @@ +OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) +ENTRY(__pcrt_entry) + +MEMORY { + kernel (!a) : ORIGIN = 0x00000000, LENGTH = 0x08000000 + user (awx) : ORIGIN = 0x08000000, LENGTH = 0xf8000000 +} + +SECTIONS { + .__pcrt_before_main : { + __pcrt_before_main_start = .; + *(.__pcrt_before_main) + __pcrt_before_main_end = .; + } + + .__pcrt_before_quit : { + __pcrt_before_quit_start = .; + *(.__pcrt_before_quit) + __pcrt_before_quit_end = .; + } +}
\ No newline at end of file diff --git a/src/user/runtimes/c/entry.asm b/src/user/runtimes/c/entry.asm new file mode 100644 index 0000000..bba8060 --- /dev/null +++ b/src/user/runtimes/c/entry.asm @@ -0,0 +1,42 @@ +bits 32 + +global __pcrt_entry +global __pcrt_quit + +extern main +extern __pcrt_before_main_start +extern __pcrt_before_main_end +extern __pcrt_before_quit_start +extern __pcrt_before_quit_end + +section .text +__pcrt_entry: + mov esp, stack + push edx + + mov ebx, __pcrt_before_main_start +.before_main_loop: + cmp ebx, __pcrt_before_main_end + je .call_main + call dword [ebx] + add ebx, 4 + jmp .before_main_loop + +.call_main: + call main + +__pcrt_quit: + mov ebx, __pcrt_before_quit_start +.before_quit_loop: + cmp ebx, __pcrt_before_quit_end + je .end_task + call dword [ebx] + add ebx, 4 + jmp .before_quit_loop + +.end_task: + int 0x38 + +section .stack nobits alloc noexec write align=16 +resb 4096 +stack:
\ No newline at end of file |