how can i get size of kernel from grub?
i'm use multiboot and i can pass it to kernel. but i can not found any thing about kernel size in it.
kerel size grub
Re: kerel size grub
Hello,
If loadEndAddr and loadAddr are set in your multiboot header then the size is simply the difference between them. If they are not set, you may need to have to figure it out youself: If you are using GCC with LD, you can define a start and end symbol in the linker script and use that to find the size of your kernel. Or, have the kernel parse its headers to obtain its size.
If loadEndAddr and loadAddr are set in your multiboot header then the size is simply the difference between them. If they are not set, you may need to have to figure it out youself: If you are using GCC with LD, you can define a start and end symbol in the linker script and use that to find the size of your kernel. Or, have the kernel parse its headers to obtain its size.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: kerel size grub
how can i do this?If you are using GCC with LD, you can define a start and end symbol in the linker script and use that to find the size of your kernel. Or, have the kernel parse its headers to obtain its size.
can i use elf section of multiboot_info?
Re: kerel size grub
pswin,
Add something like " kernel_end = . ; " to the end of the SECTIONS parts of your linker script
Then you can then use the address of kernel_end to work out the kernel size.
- gerryg400
Add something like " kernel_end = . ; " to the end of the SECTIONS parts of your linker script
Code: Select all
SECTIONS
{
OTHER SECTIONS GO HERE
kernel_end = . ;
}
- gerryg400
If a trainstation is where trains stop, what is a workstation ?
Re: kerel size grub
i do this:
entry.s
and in main.c:
my kenel binary size is 24kb but it retun just 20.5kb
y?
and what is wrong?
entry.s
Code: Select all
start:
; Load multiboot information:
push end
push start
push ebx
; Execute the kernel:
cli ; Disable interrupts.
call kmain ; call our main() function.
hlt ; halt system
Code: Select all
int kmain( multiboot_info_t *mbi,size_t kstart,size_t kend)
...
printf("kernel size is: %d", kend - 0x100000);
y?
and what is wrong?
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: kerel size grub
Part of the kernel executable is taken up by a header that describes how to load the kernel into memory, which is used by the bootloader. This header is not itself loaded, so it doesn't take up any space: this leads to a slightly (~4 KB depending) smaller in-memory kernel image than on-disk kernel image.