Whats the problem with ld linker???

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
Unexpected

Whats the problem with ld linker???

Post by Unexpected »

I don't understand, what the problem
In what file format is kernel?
In flat binary yea?
I have a grub loader in fat12 floppy...
Grub loading kernel.bin file....
I compiled all correct... I do all what was wrote in this forum...
But my kernel doesn't load!
I try with grub... but grub wrote "Bad executable format" or smth...
What can I do?
Tom

Re:Whats the problem with ld linker???

Post by Tom »

I don't use grub or know anything about it, but...
is the file format that you selected to boot flat binary?
Dave_Hunt

Re:Whats the problem with ld linker???

Post by Dave_Hunt »

Try using ELF format and make sure your multiboot header is correct and at or near the beginning of your kernel image.

Check here for a good tutorial on using GRUB:

http://osdev.neopages.net/docs.php
Unexpected

Re:Whats the problem with ld linker???

Post by Unexpected »

I compiling like this:
gcc -c kernel.c -o kernel.o
ld -T kernel.ld kernel.o

kernel.ld file is like this:

OUTPUT_FORMAT("binary")
ENTRY(_start)
SECTIONS
{
.text 0x100000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{                
*(.bss)
}
}


Is there smth wrong?
Thnx.
Dave_Hunt

Re:Whats the problem with ld linker???

Post by Dave_Hunt »

The problem isn't just with the way you linked. The problem is that you have to use a format that GRUB recognizes. This includes setting up a valid multiboot header in your executable image that tells GRUB what format you used and how to deal with it. Take a look at the tutorial I mentioned. It's all explained there.
Unexpected

Re:Whats the problem with ld linker???

Post by Unexpected »

How about when I use not a grub, I use simple boot code, witch loads the kernel, sets pmode and jumps to 0x1000:0x0000
Kernel is placed in sector 1.
In what format I need to compile the kernel?
Boot sector works fine, but with kernel something wrong... Is nothing happens or rebooting PC...
My kernel is verys simple just printf and freeze funtions.
Wath the problem?

Please help...
Tom

Re:Whats the problem with ld linker???

Post by Tom »

Try some of my code...I don't know what's wrong with your C Kernel untill I see your code too...Where did you get your printf and freeze function?
PlayOS

Re:Whats the problem with ld linker???

Post by PlayOS »

[attachment deleted by admin]
Unexpected

Re:Whats the problem with ld linker???

Post by Unexpected »

Very thank you!
My kernel works fine :D
THANX!!!
Post Reply