diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/boot.s | 1 | ||||
| -rw-r--r-- | src/crti.s | 16 | ||||
| -rw-r--r-- | src/crtn.s | 10 | ||||
| -rw-r--r-- | src/kernel.c | 9 |
4 files changed, 35 insertions, 1 deletions
@@ -84,6 +84,7 @@ _start: stack since (pushed 0 bytes so far), so the alignment has thus been preserved and the call is well defined. */ + call _init call kernel_main /* diff --git a/src/crti.s b/src/crti.s new file mode 100644 index 0000000..30dd4ea --- /dev/null +++ b/src/crti.s @@ -0,0 +1,16 @@ +/* x86 crti.s */ +.section .init +.global _init +.type _init, @function +_init: + push %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: + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ diff --git a/src/crtn.s b/src/crtn.s new file mode 100644 index 0000000..1da795d --- /dev/null +++ b/src/crtn.s @@ -0,0 +1,10 @@ +/* x86 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 diff --git a/src/kernel.c b/src/kernel.c index dd81d33..2c71ba4 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -111,14 +111,21 @@ void terminal_writestring(const char* data) { terminal_write(data, strlen(data)); } + +char *rec; +__attribute__ ((constructor)) void foo(void) +{ + rec="aleksa"; +} void kernel_main(void) { terminal_initialize(); - for(size_t i=0;i<80;i++) + for(size_t i=0;i<50;i++) { for(size_t j=0;j<i;j++) terminal_writestring("#"); terminal_writestring("Hello, kernel World!\n"); } + terminal_writestring(rec); } |
