Kernel doesn't fit into memory (?)

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
Whatever5k

Kernel doesn't fit into memory (?)

Post by Whatever5k »

When I try to build my kernel with elf, there's the error message:
"ld: kernel.bin: Not enough space for program headers, try linking with -N"
Ok, I did so and it worked. Now I tried to load my kernel with GRUB, but the following error message is printed:
"Kernel does not fit into memory"

What's wrong? My kernel is only 10878 bytes big...
Can somebody help me please?
Whatever5k

Re:Kernel doesn't fit into memory (?)

Post by Whatever5k »

Ok now I do not have the message
"Not enough room for program headers..."
anymore - I fixed s.th. in the linker script.
But still, GRUB sais that the kernel doesn't fit into memory...
Please help me...
This here is my linker script:

Code: Select all

OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
SECTIONS
{
    .text 0x100000 :   /* 1 meg */
    {
/* kernel code */
   code = .; _code = .; __code = .;
   *(.text)
    }
    .data :
    {
/* kernel data */
   data = .; _data = .; __data = .;
   *(.data)
    }
    .bss :
    {
/* kernel BSS */
   bss = .; _bss = .; __bss = .;
   *(.bss)
   *(COMMON) /* GNU C "common" variables */
    }
    end = .; _end = .; __end = .;
}
Help, please
Whatever5k

Re:Kernel doesn't fit into memory (?)

Post by Whatever5k »

Hey, really nobody ever had this problem before me?
Come on... ;)
Whatever5k

Re:Kernel doesn't fit into memory (?)

Post by Whatever5k »

Hm, perhaps GRUB cannot load my kernel because I move the GDT to 0x500. Might this be the problem?
Dave_Hunt

Re:Kernel doesn't fit into memory (?)

Post by Dave_Hunt »

No. GRUB doesn't know where your GDT is.

Did you perhaps declare an exceptionally large array somewhere in your C code? If so, it would get stuck in the .bss section and wouldn't show up in your file size.

What does objdump -h show you?
Whatever5k

Re:Kernel doesn't fit into memory (?)

Post by Whatever5k »

Hm, I have created a bss section (zero'd it) and reserved 4096 bytes (4Kb) for it. This should be enough, shouldn't it?
Of course I reserve some char-arrays (char buffer[MAXLEN], MAXLEN is 500), but this should be sufficient...

I really am in big trouble, I do not know what to do..:(
Dave_Hunt

Re:Kernel doesn't fit into memory (?)

Post by Dave_Hunt »

What does objdump -h show you?
Post Reply