Page 1 of 1
Where Grub loads your kernel.
Posted: Thu Aug 08, 2002 11:00 pm
by rexlunae
Is there a good way to know what memory your kernel image is using after grub loads it?
RE:Where Grub loads your kernel.
Posted: Thu Aug 08, 2002 11:00 pm
by carbonBased
You should already know!
You have to tell GRUB where to load your kernel. It's in the multiboot header you defined in order to let GRUB load your kernel.
That's the starting address, anyway.
If, by chance, you mean, how to find out how _large_ your kernel is, there's at least a few ways.
In my case, I define the whole multiboot header, with AOUT_KLUDGE set. Even though I am using ELF, I included the kludge under the chance that I sometime in the future I use a different object/executable format.
I used a linker script to define these values, and you could to. Just define an address at the end of the bss section, and that will be the end, or size, of your kernel.
GRUB will also include a symbol table for your AOUT or ELF binary, which can possibly be used to find the size of your kernel (I have investigated this, but I'm sure it's possible).
Also, if you plan on using kernel modules, you can get the absolute end of kernel used memory but checking the address of the last kernel module, and adding it's length. GRUB loads the kernel modules sequentially after the kernel, and therefore the last kernel module will be the last address used by the kernel.
Cheers,
Jeff
RE:Where Grub loads your kernel.
Posted: Fri Aug 09, 2002 11:00 pm
by rexlunae
Thanks for responding to my question.
I have to say to myself RTFM. Upon reviewing the documentation I have on multiboot, I realized that for ELF, information on section headers is passed in the boot struct. I thought this was just the symbol table at first, but that is only for a.out.