Kernel Linking Question

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
User avatar
xfelix
Member
Member
Posts: 25
Joined: Fri Feb 18, 2011 5:40 pm

Kernel Linking Question

Post 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!!
The More I See, The More I See There Is To See!
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Kernel Linking Question

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Kernel Linking Question

Post 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 ;)
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Post Reply