In my kernel(x86, 32bit) I have some casual code to fill an array with 0's:
Code: Select all
for (u32 i = 0; i < 1024; i++) {
pageDirectory[i] = 0;
}
Code: Select all
pageDirectory = (u32 *)((((u32)&kernel_end) & 0xfffff000) + 0x1000) ;
I am sure that pageDirectory is greater than &kernel_end(I've printed it to the screen, and printing'em out in gdb confirms that). What the hell am I doing wrong?
I compile the code with clang: clang -g -c -m32 -ffreestanding -fno-builtin -nostdlib -nostdinc -nostdinc++ -std=c++11 -fno-rtti paging.cpp -o paging.cpp.o
And link it with ld(from binutils compiled by myself): ~/opt/cross/bin/i586-elf-ld -L ~/opt/cross/lib/gcc/i586-elf/4.8.1/ -lgcc -T link.ld -o agos paging.cpp.o (and some more *.o files here of course)
this is my linker script:
Code: Select all
ENTRY(_start)
SECTIONS
{
. = 1M;
kernel_start = .;
.text : ALIGN(4K) {
*(.multiboot)
*(.text)
}
.rodata : ALIGN(4K) {
*(.rodata)
}
.data : ALIGN(4K) {
*(.data)
}
.bss : ALIGN(4K) {
*(COMMON)
*(.bss)
*(.bootstrapStack)
}
kernel_end = .;
}