[solved] Problem with linker
Posted: Wed Mar 09, 2011 1:44 pm
Hello everyone.
I am fairly new to C, but I know enough to make a sample C kernel. However I am having trouble with linking my kernel.
1) I am sure my ASM code works
2) My C code is simple so I don't think there is a problem there...
My kernel compiles, assemblers, and links without error, but my code never makes it to the C code, infact, it never launches the kernel corectly. It works like this:
Now this is when we set P-mode and jump to the kernel. The kernel should automatically clear the screen (No "OK!" message should be displayed for PM)
I know my bootstrap is not the one at fault because I wrote it for my ASM kernel and have used it a while. Since it loads raw binary to 0x7E00 I have tried to configure my linker to handle this based from the one in "Bare_Bones". Here is the linker script:
As far as I can understand it should work, but obviously my understanding is wrong...
All code attached below... ( /!\ Code is built with Linux Makefile! [ bootstrap uses FASM, header uses NASM and kernel uses GCC, havn't taken time to convert bootstrap to NASM yet, sorry...] just run the makefile and it should make a bootible floppy.)
Any guide lines, tips, pointes, help, will be appreciated.
I am fairly new to C, but I know enough to make a sample C kernel. However I am having trouble with linking my kernel.
1) I am sure my ASM code works
2) My C code is simple so I don't think there is a problem there...
My kernel compiles, assemblers, and links without error, but my code never makes it to the C code, infact, it never launches the kernel corectly. It works like this:
- Boot loader launches, and loads kernel.
- Boot loader sets 32bit paging (located at 0x00001000), Puts IDT at 0x00000000, Sets PIT, maps PIC, lastly, sets P-Mode and jumps to kernel.
Code: Select all
Loading sectors... OK!
Installing paging... OK!
Entering P-mode...
I know my bootstrap is not the one at fault because I wrote it for my ASM kernel and have used it a while. Since it loads raw binary to 0x7E00 I have tried to configure my linker to handle this based from the one in "Bare_Bones". Here is the linker script:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY (start)
SECTIONS{
. = 0x00007e00; /* This should tell it were the kernel is loaded.. no? */
.text :{
*(.text)
}
.data : {
*(.data)
}
.bss : {
sbss = .;
*(COMMON)
*(.bss)
ebss = .;
}
}
INPUT(head.o kernel.o)
OUTPUT(kernel.bin)
All code attached below... ( /!\ Code is built with Linux Makefile! [ bootstrap uses FASM, header uses NASM and kernel uses GCC, havn't taken time to convert bootstrap to NASM yet, sorry...] just run the makefile and it should make a bootible floppy.)
Any guide lines, tips, pointes, help, will be appreciated.