calling functions written in c from your bootloader?
Posted: Wed Feb 11, 2015 9:27 pm
Hello,
I am trying to call c functions from my bootloader. Suppose I am in 32-bit protected mode in my bootloader and I want to call some c functions for easier data manipulation such as parsing kernel elf header and loading it in to memory. How would I link my bootloader with my c functions? Suppose my loader is called bootloader.asm and c function file is call function.c.
I tried linking them but it didn't work cause it added some stuff at the end of the binary...
x86_64-elf-gcc -c function.c
nasm -f bootloader.asm -o bootloader.o
ld -melf_i386 -Ttext 0x7c00 function.o bootloader.o -o bootloader.bin --oformat binary
I am trying to call c functions from my bootloader. Suppose I am in 32-bit protected mode in my bootloader and I want to call some c functions for easier data manipulation such as parsing kernel elf header and loading it in to memory. How would I link my bootloader with my c functions? Suppose my loader is called bootloader.asm and c function file is call function.c.
I tried linking them but it didn't work cause it added some stuff at the end of the binary...
x86_64-elf-gcc -c function.c
nasm -f bootloader.asm -o bootloader.o
ld -melf_i386 -Ttext 0x7c00 function.o bootloader.o -o bootloader.bin --oformat binary