c runtime library for hosted executables

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
captainwiggles
Posts: 23
Joined: Tue Nov 11, 2008 3:03 pm

c runtime library for hosted executables

Post by captainwiggles »

Hey guys, this is my first real post here so please let me know if this should be in OS design & theory instead of here or any other probs.

I working on a monolithic x86 kernel for my university dissertation. I've got the basics done, and am close to starting multitasking, so of course I had to eventually set up a proper cross compiler and tool chain. Using http://wiki.osdev.org/GCC_Cross-Compiler and http://wiki.osdev.org/OS_Specific_Toolchain

I can now compile and link my kernel to an elf binary.

However I'm slightly confused with the os specific toolchain part, I sorted binutils and gcc and built them, however I don't want to use newlib as my c runtime, I want to code this myself. So I ignored the bit about newlib.

Now I compile my basic test prog (I have no api yet, thats coming later, the prog consists of "int main(void){ return 2+3; }") which is fine, however of course when it comes to linking it fails expecting crt0.o.

So as mentioned in the tutorial I created crt0.asm consisting of

Code: Select all

global _start
extern main
_start:
call main
jmp $
I'll worry about exiting later.

Now when i link against this its fine.

My questions are:

1) how can i configure ld to know where my crt0.o and other runtime libraries are by default, i'm currently using --nostdlib and manually specifying crt0.o

2) Is this going to work?

Thanks for any help, it'll be much appreciated.

Wiggles
Post Reply