After switching to higher half, kernel address is corrupted
Posted: Mon Aug 29, 2016 11:06 pm
Hi.
I recently enabled paging with higher half kernel.
Since then, accessing kernel start and end address variables I declared in the linker script returns wrong addresses.
This is my linker script
The correct start addresses should be: (according to readelf)
When I print the address I get wrong address:
The actual code to print it:
Before enabling paging, this code worked perfectly.
What am I missing ?
I recently enabled paging with higher half kernel.
Since then, accessing kernel start and end address variables I declared in the linker script returns wrong addresses.
This is my linker script
Code: Select all
ENTRY(EntryPoint)
OUTPUT_FORMAT(elf32-i386)
ENTRY_BASE = 0x100000;
CODE_VIRT = 0xC0000000;
SECTIONS {
/* The kernel will live at 3GB + 1MB in the virtual
address space, which will be mapped to 1MB in the
physical address space. */
. = ENTRY_BASE;
.boot : {
*(.multiboot)
_ *(.bootcode)
*.(bootstack)
}
. += CODE_VIRT;
.text : AT(ADDR(.text) - 0xC0000000) {
kernel_start = .;
*(.text)
*(.rodata*)
}
kernel_end = .;
.data ALIGN (0x1000) : AT(ADDR(.data) - 0xC0000000) {
*(.data)
}
.bss : AT(ADDR(.bss) - 0xC0000000) {
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
}
Code: Select all
[ 4] .text PROGBITS c0104820 005820 0020e8 00 AX 0 0 16
[ 5] .data PROGBITS c0107000 008000 002000 00 WA 0 0 4096
[ 6] .bss NOBITS c0109000 00a000 008030 00 WA 0 0 4096
[ 7] .debug_info PROGBITS 00000000 00a000 0024ae 00 0 0 1
Kernel start: 0x3fefb7e0, kernel end: 0x3fef96f8
The actual code to print it:
Code: Select all
extern uint32_t kernel_start;
extern uint32_t kernel_end;
printk("Kernel start: 0x%x, kernel end: 0x%x\r\n", (uint32_t) &kernel_start, (uint32_t) &kernel_end);
What am I missing ?