Calculate size of the kernel based on symbols defined in the linker script

Neat trick!
This commit is contained in:
Eryn Wells 2016-03-25 00:39:11 -04:00
parent 4daee62439
commit ddb4c30c62
2 changed files with 12 additions and 0 deletions

View file

@ -22,6 +22,9 @@
#error "This file should be compiled with an ix86-elf compiler!"
#endif
extern u32 kernelStart;
extern u32 kernelEnd;
/** The beginning of the world... */
extern "C"
@ -37,6 +40,12 @@ kmain(multiboot::Information *information,
auto& console = kernel.console();
auto start = u32(&kernelStart);
auto end = u32(&kernelEnd);
console.printFormat("Kernel start: 0x%08lX\n", start);
console.printFormat("Kernel end: 0x%08lX\n", end);
console.printFormat("Kernel size: %ld bytes\n", end - start);
console.printFormat("Command line: \"%s\"\n", info->commandLine());
console.printFormat("Memory map:\n");