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.
I'm having trouble with linkers. Is a linker really necessary? If I have the following sources:
- kernel.c
- video.c
would I be able to compile and link them with gcc?
Yes, you always need a linker (at the risk of generalizing).
If you have more then one object file, you will need a linker to combine the two. Even if you have only one object file, you will typically need a linker to create the resultant executable (very few compilers output executables... I can't think of any off hand, as it's simply not practical).
When you envoke GCC in this way, it envokes ld, the GNU linker.
The GCC executable is a front end to the GNU C compiler, and linker (among many other things).
Thank you, that helped me clarify a couple things about compiling and linking. My next question is if I have two object files and the boot sector compiled with nasm and am going to use ld linker to link them. Is a linker script necessary and if so where might I find a good tutorial on ld scripting?
A linker script isn't always necessary, no. However, in OSDev'ing, it's often very useful to know how to write one so I would still suggest reading up on them.
A linker script will allow you to directly place/align sections where you want, define symbols at specific addresses, etc.
Just searching for gnu ld scripts will probably find some useful info. I was able to find ld script basics from various online docs.
In your case, yes, you would use a linker (ie, ld) to link them. This is a perfect instance where a link script comes in handy, as you want to ensure that your boot sector is the first object in the resultant binary (although, if you know ld, you'll realize that providing it as the first object on the command line will do the same thing... but this isn't necessarily defined in the ld specs).