Problem loading Kernel with Grub

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
ich_will

Problem loading Kernel with Grub

Post by ich_will »

After I've downloaded a new version of ld(2.15.90.0.1.1 20040303 SuSE Linux) and gcc(3.3.3 SuSE Linux), grub wouldn't load my kernel. Before updating it works.

That's my linkerscript:

Code: Select all

/* Link.ld */

/*OUTPUT_FORMAT("binary") it seems that this doesn't work under Linux (I knew you have to add the AOUT_KLUGDE in your start.asm*/

OUTPUT_FORMAT("elf32-i386")

ENTRY(start)
SECTIONS
{
   .text 0x100000 :
   {
      *(.text)
      code = .; _code = .; __code = .;
      . = ALIGN(4096);
   }

   .data :
   {
      /* only for cpp ??? */
      /*__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
      __DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .;*/

      *(.data)
      data = .; _data = .; __data = .;
      . = ALIGN(4096);
   }

   .bss :
   {
      *(.bss)
      bss = .; _bss = .; __bss = .;
      . = ALIGN(4096);
   }

   end = .; _end = .; __end = .;
}
and that's the commando which I use to link all together:
$(LD) -T link.ld *.o -o ../kernel.bin
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:Problem loading Kernel with Grub

Post by Pype.Clicker »

the .ctors and .dtors sections were Djgpp-specific (or gcc 2.95.y specific), iirc ... you should get the newly-defined C++ ABI and see how you're expected to find information about global objects ...
ich_will

Re:Problem loading Kernel with Grub

Post by ich_will »

Thank you for replying, but what means ABI do you mean API? I programm only in c not in cpp. I find out that grub is able to load my kernel if I write else it won't find out which kernel type I use:

kernel --type=netbsd (fd0)/boot/kernel.bin

but then grub doesn't pass the multiboot info struct address to eax. What can I do? I'm using grub 0.94.
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:Problem loading Kernel with Grub

Post by Pype.Clicker »

API is an Application Programming Interface, ie a collection of functions that you (as a programmer) can use to interoperate with some code.

the ABI is the Apllication BINARY interface, ie a collection of rules that the compiler/linker/loader have to follow in order to produce interoperable objects. For instance, the ABI will define how symbol names should be presented (that can be as easy as putting an '_' in front of the symbol name, or be as complex as C++ name mangling)
ich_will

Re:Problem loading Kernel with Grub

Post by ich_will »

Where can I find the ABI? And do I need it if I only programm in C? What can I do for grub pass the multiboot info structur to the kernel?

Has no one else this problem with new compiler and linker tools for SuSE linux 9.1?

P.S.: Sorry for my bad english.
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:Problem loading Kernel with Grub

Post by Pype.Clicker »

http://www.codesourcery.com/cxx-abi/ was the place i found it ... a google search (GCC C++ ABI) might give you more recent/generic stuff, though...
ich_will

Re:Problem loading Kernel with Grub

Post by ich_will »

I don't realy know why this document would help. But I got it working. I've to write:

ld -T link.ld --omagic *.o -o ../kernel

the --omagic option is it
Post Reply