I now have this C code:
Code: Select all
/* <TODO> display the size of the kernel */
extern unsigned long kernel_end;
extern unsigned long kernel_start;
kprintf("Kernel start: 0x%x\n", &kernel_start);
kprintf("Kernel end: 0x%x\n", &kernel_end);
kprintf("Kernel size: 0x%x bytes\n", (&kernel_end - &kernel_start));
The linker script I now have is an attachment, please check it too.
This code gives the following output:
Kernel start: 0xc0100000
Kernel end: 0xc0108000
Kernel size: 0x2000
Maybe it's my knowledge of C, but I can't really understand why the result of the subtraction is 0x2000 instead of 0x8000.
EDIT: Good news:
When doing it like this:
uintptr_t end = (uintptr_t)&kernel_end;
uintptr_t start = (uintptr_t)&kernel_start;
uintptr_t size = end-start;
It works! But why? Why do I first need to assign new variables the value, and then subtract those?