Page 1 of 1

Kernel Linking Question

Posted: Sat Feb 19, 2011 6:51 pm
by xfelix
If I wanted to build some separate modules of code such as a kassert.c, kstring.c, kthread.c, etc. Do I build the relocatable object files the same way as I would for user applications, until the point of needing to actually creating the flat binary file during the link?

Currently, I have a loader.s and a kernel.c file that compose the entire EnigmaOS. The loader.s asm file contains stuff that makes GRUB happy and calls Kernel_Main of course. The kernel.c has Kernel_Main, Put_Char, strlen, Print_String, and Clear_Screen already 8)

This is really cool, but I think this code is really ugly just sitting in one file. I need some Modularization!!

Re: Kernel Linking Question

Posted: Sat Feb 19, 2011 7:44 pm
by thepowersgang
Yep, it's much the same until link time :)

Since you already have two object files (the assembler and C) it should be easy.

Re: Kernel Linking Question

Posted: Sun Feb 20, 2011 2:19 am
by xenos
There are a few differences between building object files for your kernel and building them for a user application. You need to make sure that you don't include any system headers such as stdio.h (which you would probably do for a user application) and don't use functions from any standard library. But since you already compile your kernel.c file this way, you probably already know this ;)