OK,
I've gotten to the stage where I've loaded my kernel off the floppy drive. When the kernel was in assembler, it worked fine; now I'm trying to get C working. I'm in protected mode and the stack is set up and everything. Protected mode code works in assembly, selectors work. I created the custom linker script as recommended.
The problem is when I try to link my kernel to an assembly stub that will jump into the main kernel
function. It says that it has an unresolved symbol:
_GLOBAL_OFFSET_TABLE_
LD then dies. I'm calling LD like this:
ld -T kernel.lnk stub.o kernel.o -o kernel.bin
in nasm, I'm just creating the image by:
%include 'boot.asm'
incbin 'kernel.bin'
Then dding it out to the floppy
I've tried faking that symbol, to no avail. Can someone tell me what the problem is? Please don't tell me to use a.out or coff, I'm writing the OS in BeOS, in which LD only supports elf. I believe I'm using gcc version 2.9.2
Bootloader functional; problem linking C kernel
Re:Bootloader functional; problem linking C kernel
Well, to answer my own question, I put a global in my stub so that I can link properly. I think this is a bug in ld. Oh well.
Re:Bootloader functional; problem linking C kernel
The Global Offset Table is used for ELF dynamic linking. If you're making a kernel, the kernel should probably be statically linked. Use "ld -static ..."
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Bootloader functional; problem linking C kernel
the global offset table is usually generated when you ask for generation of Position Independent Code (with -fpic). Check your compilation statements.
Re:Bootloader functional; problem linking C kernel
Hmm, I used -Bstatic before, and it still stuck around. I wasn't generating position independent code either. I'll try just -static this time and see if it works.
Thanks for your help
Thanks for your help