Global variable and 64 bits higher half kernel with GRUB2
Posted: Fri Mar 14, 2014 4:29 am
(I apologize for my english since it is not my mother-tongue)
Hi everyone,
Following this tutorial (http://wiki.osdev.org/64-bit_Higher_Hal ... ith_GRUB_2) in order to write my own OS, I encounter a weird bug.
As soon as I add global (static or not) variables in my C code, the assembly bootstrap can't reach the C main() function. The system restarts.
I tried with only the code given by the tutorial, simply changing the c code from:
to:
NB: the a and b symbols appears to be in the .bss section. If the "static" keyword is added it is no more the case, but the kernel keeps crashing.
I think it is a kind of global symbols mismatch when GRUB2 loads the ELF64 file, but I still can't figure out what is wrong since I am not an expert in the ELF64 format.
Hi everyone,
Following this tutorial (http://wiki.osdev.org/64-bit_Higher_Hal ... ith_GRUB_2) in order to write my own OS, I encounter a weird bug.
As soon as I add global (static or not) variables in my C code, the assembly bootstrap can't reach the C main() function. The system restarts.
I tried with only the code given by the tutorial, simply changing the c code from:
Code: Select all
int main()
{
while (1);
}
Code: Select all
int a;
int b[20];
int main()
{
while (1);
}
I think it is a kind of global symbols mismatch when GRUB2 loads the ELF64 file, but I still can't figure out what is wrong since I am not an expert in the ELF64 format.