LibC: Dummy ctr* files for i386
This allows compilation of libc for i386 targets
This commit is contained in:
33
libc/arch/i386/crt0.S
Normal file
33
libc/arch/i386/crt0.S
Normal 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
16
libc/arch/i386/crti.S
Normal 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
10
libc/arch/i386/crtn.S
Normal 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
|
||||||
Reference in New Issue
Block a user