I'm writing my own kernel (using multiboot2) and have followed this tutorial to bring it into long-mode. I am now linking with the following C code:
void kernel_main()
{
  *(uint64_t*) 0xb8000 = 0x2f592f412f4b2f4f;
}
This prints OKAY to the screen.
However, I now create a global variable called VGA_buffer that holds this memory address.
volatile static const void* VGA_buffer = 0xb8000;
void kernel_main()
{
  *(uint64_t*) VGA_buffer = 0x2f592f412f4b2f4f;
}
The code is no longer working, OKAY is not appearing on the screen.
How do I fix this?
I think this is because my linker script is not including the global variable data. This is what I've got:
ENTRY(start)
SECTIONS
{
  . = 1M;
  .boot :
  {
    *(.multiboot_header)
  }
  .text :
  {
    *(.text)
  }
}
I also tried adding the following with no luck:
...
.rodata :
{
  *(.rodata)
}
.data :
{
  *(.data)
}
.bss :
{
  *(.bss)
}
I'm not very familiar with custom linker scripts so I really don't know what I'm doing, and I'm not sure if this is even the problem.
 
     
    