multiboot structures
multiboot structures
is there any way through the multiboot structures (I use grub) to find out the size of the kernel image? it would really help me in setting up a memory manager (so I don't write over the kernel image ;D) thanks
Re:multiboot structures
you could do that with the use of your linker script, which is a much better way to find the kernel size at runtime.
you will have to use variables in your linker script to do this. IIRC this has been discussed here in detail sometime previously. HTH
you will have to use variables in your linker script to do this. IIRC this has been discussed here in detail sometime previously. HTH
Re:multiboot structures
Imagine u have this linker script:
In you code use can get the size of the kernel easily:
Remember to add the 'extern' statement to say the compiler that _start and _end are located outside this source file.
Compile your kernel with the '-T <linker script>' flag.
Code: Select all
ENTRY (_loader)
SECTIONS
{
. = 0x00100000;
_start = .;
.text :
{
*(.text)
*(.rodata)
}
.data ALIGN (0x1000) :
{
*(.data)
}
.bss :
{
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
_end = .;
}
Code: Select all
extern void _start, _end;
unsigned int kernelGetSize(void) {
return (unsigned int)&_end - (unsigned int)&_start;
}
Compile your kernel with the '-T <linker script>' flag.
Re:multiboot structures
So does that return the size of the kernel as it exists on file, or the size of the block of memory the kernel occupies once it has been fully loaded by the bootloader?