Bran's kernel dev tutorial problem

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
deficite

Bran's kernel dev tutorial problem

Post by deficite »

I'm getting an error 13, and rightly so, my multiboot header keeps getting put near the end of my binary. I don't know a whole lot about ASM and linker scripts, but it looks like it should work to me (and I followed Bran's tutorial to the T on these two things)

Here's a post about this I made on OSDev's message board: http://www.osdev.org/phpBB2/viewtopic.php?t=2662
LongHorn

Re:Bran's kernel dev tutorial problem

Post by LongHorn »

May be it's because there are some additional sections. You should compile sources with some options and try to use someother format instead of binary format.
Bob the Avenger

Re:Bran's kernel dev tutorial problem

Post by Bob the Avenger »

try:

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
  .text phys : AT(phys) {
    *(mboot)
    code = .;
    *(.text)
    . = ALIGN(4096);
  }
  .data : AT(phys + (data - code))
  {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss : AT(phys + (bss - code))
  {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .;
}
This should ensure the mboot label should be the first thing in your binary
deficite

Re:Bran's kernel dev tutorial problem

Post by deficite »

Bah...it's still not working even after using your linker script. Thanks anyway. I think I'm just going to try using elf instead of binary and see if it works out.

edit: I switched over to ELF and now everything works.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Bran's kernel dev tutorial problem

Post by Colonel Kernel »

My kernel is just a flat binary, and it works for me. I just make sure that the .o file containing my multiboot header is the very first input file listed in the command line parameters sent to ld.

Hope this helps.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bran's kernel dev tutorial problem

Post by Pype.Clicker »

when creating a multiboot binary (i mean, flat), you're really suggested to ask the linker for a symbol map, and check things are in place.

you may have it with "ld --print-map" (on stdout) or "ld -M -Map kernel.map", for instance.
astrocrep

Re:Bran's kernel dev tutorial problem

Post by astrocrep »

I am getting stuck on this problem...

I tried your linker script and also tried output "elf32-i386"

Neither worked...

Grub gives the error 13.

Thanks,
Rich
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bran's kernel dev tutorial problem

Post by Pype.Clicker »

make sure you've read the "BareBones" and "HigherHalfBareBones" pages of the FAQ, then.

And if you could also post what "objdump -x YourKernel.elf" (the first lines: i don't care of symbols or cross-references), that may explain what's wrong.
astrocrep

Re:Bran's kernel dev tutorial problem

Post by astrocrep »

Nevermind...

I just got it WORKING!!

Thanks all!

-Rich
User avatar
Solar
Member
Member
Posts: 7635
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Bran's kernel dev tutorial problem

Post by Solar »

astrocrep wrote: Nevermind...

I just got it WORKING!!
And what, pray, was your solution? It might help others, you know...
Every good solution is obvious once you've found it.
Post Reply