I am trying to write a basic OS to better understand OS fundamentals and I am running into a strange problem. After switching to protected mode I jump into my kernel. In my kernel.cpp file I declare the following global variables (where IdtPointer_t and IdtEntry_t are both structs.)
IdtPointer_t idtPtr;
IdtEntry_t idtEntries[256];
This creates the idtPtr and idtEntries variables in the bss section. Then later in my code when I do the following
IdtEntry_t* entry = &idtEntries[0];
the value returned by &idtEntries[0] isn't the correct address. Using GDB I have done the following
p &idtEntries[0]
(IdtEntry_t *) 0x87a0 <idtEntries>
p entry
(IdtEntry_t *) 0x87e0 <idtEntries+64>
There is a 64 byte difference between the locations of the two variables. Why does referencing the variable return a different address than where the variable is stored in memory?
Also, I am running this using the qemu i386 emulator.