Page 1 of 1

Bran's kernel dev tutorial problem

Posted: Thu Jun 22, 2006 12:20 pm
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

Re:Bran's kernel dev tutorial problem

Posted: Thu Jun 22, 2006 12:52 pm
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.

Re:Bran's kernel dev tutorial problem

Posted: Thu Jun 22, 2006 1:06 pm
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

Re:Bran's kernel dev tutorial problem

Posted: Thu Jun 22, 2006 1:19 pm
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.

Re:Bran's kernel dev tutorial problem

Posted: Thu Jun 22, 2006 3:02 pm
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.

Re:Bran's kernel dev tutorial problem

Posted: Fri Jun 23, 2006 5:46 am
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.

Re:Bran's kernel dev tutorial problem

Posted: Fri Jun 23, 2006 9:33 pm
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

Re:Bran's kernel dev tutorial problem

Posted: Sat Jun 24, 2006 12:03 pm
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.

Re:Bran's kernel dev tutorial problem

Posted: Sat Jun 24, 2006 12:53 pm
by astrocrep
Nevermind...

I just got it WORKING!!

Thanks all!

-Rich

Re:Bran's kernel dev tutorial problem

Posted: Wed Jul 12, 2006 12:04 am
by Solar
astrocrep wrote: Nevermind...

I just got it WORKING!!
And what, pray, was your solution? It might help others, you know...