Code: Select all
#include <stdint.h>
#define VGA_MEM 0x000B8000
__attribute__((noreturn))
void exception_handler(void)
{
char* msg = "Exception occurred";
uint16_t* fb = (uint16_t*)VGA_MEM;
for (int i = 0; msg[i]; i++)
{
fb[i] = msg[i] | (0x07 << 8);
}
__asm__ volatile ("cli; hlt");
while(1);
}when i launch bochs with kernel.elf containing this char* msg, it says Grub Error 13 invalid executable format
but if i put char[] msg then it works. Please can you help me
link.ld file
Code: Select all
ENTRY(loader) /* the name of the entry label */
SECTIONS {
. = 0x00100000; /* the code should be loaded at 1 MB */
.text ALIGN (0x1000) : /* align at 4 KB */
{
*(.text) /* all text sections from all files */
}
.rodata ALIGN (0x1000) : /* align at 4 KB */
{
*(.rodata*) /* all read-only data sections from all files */
}
.data ALIGN (0x1000) : /* align at 4 KB */
{
*(.data) /* all data sections from all files */
}
.bss ALIGN (0x1000) : /* align at 4 KB */
{
*(COMMON) /* all COMMON sections from all files */
*(.bss) /* all bss sections from all files */
}
}