LibC: Dummy ctr* files for i386

This allows compilation of libc for i386 targets
This commit is contained in:
Bananymous 2024-03-21 15:20:20 +02:00
parent 65750586b6
commit 7d1b7436d4
3 changed files with 59 additions and 0 deletions

33
libc/arch/i386/crt0.S Normal file
View File

@ -0,0 +1,33 @@
.section .text
.global _start
_start:
# zero out stack frame
pushl $0
pushl $0
movl %esp, %ebp
# FIXME: handle stack alignment
ud2
# push argc, argv, environ for call to main
pushl %edx
pushl %esi
pushl %edi
# initialize libc
pushl %edx
call _init_libc
addl $4, %esp
# call global constructos
call _init
# call main, arguments are already on stack
call main
# cleanly exit the process
pushl %eax
call exit
.size _start, . - _start

16
libc/arch/i386/crti.S Normal file
View File

@ -0,0 +1,16 @@
/* i386 crti.s */
.section .init
.global _init
.type _init, @function
_init:
pushl %ebp
movl %esp, %ebp
/* gcc will nicely put the contents of crtbegin.o's .init section here. */
.section .fini
.global _fini
.type _fini, @function
_fini:
pushl %ebp
movl %esp, %ebp
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */

10
libc/arch/i386/crtn.S Normal file
View File

@ -0,0 +1,10 @@
/* i386 crtn.s */
.section .init
/* gcc will nicely put the contents of crtend.o's .init section here. */
popl %ebp
ret
.section .fini
/* gcc will nicely put the contents of crtend.o's .fini section here. */
popl %ebp
ret