too many function calls corrupts the kernel image
Posted: Tue Jul 03, 2012 9:22 pm
Greetings,
I've got something of an odd problem with my kernel image.
I was writing a register dump function to dump the register contents when a page fault occurs, using the registers_t struct from the James Molloy tutorial series. I've written my own hack up of vsprintf for handling the formatting, and thus dump_registers() looks like this:
(print_buffer is a global symbol pointing at 512 bytes in .bss)
This works fine. But if i add one more call to vsprintf, Grub fails to load the entire kernel image, citing error 13.
The ELF header of the image itself looks fine when examined with objdump, So I can't see anything obviously wrong, perhaps an alignment issue or similar. I tried a few other things as well and noticed that
any additional function calls from within dump_registers to either vsprintf or console_putstr sets off the corruption issue.
I'm at a loss to explain why. Any ideas?
I've got something of an odd problem with my kernel image.
I was writing a register dump function to dump the register contents when a page fault occurs, using the registers_t struct from the James Molloy tutorial series. I've written my own hack up of vsprintf for handling the formatting, and thus dump_registers() looks like this:
Code: Select all
void dump_registers(registers_t regs)
{
vsprintf(print_buffer, "\neax: %08x\tebx: %08x\tecx: %08x\tedx: %08x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
console_putstr(DFL_ATTRIB, print_buffer);
vsprintf(print_buffer, "edi: %08x\tesi: %08x\tebp: %08x\tesp: %08x\n", regs.edi, regs.esi, regs.ebp, regs.esp);
console_putstr(DFL_ATTRIB, print_buffer);
}
This works fine. But if i add one more call to vsprintf, Grub fails to load the entire kernel image, citing error 13.
The ELF header of the image itself looks fine when examined with objdump, So I can't see anything obviously wrong, perhaps an alignment issue or similar. I tried a few other things as well and noticed that
any additional function calls from within dump_registers to either vsprintf or console_putstr sets off the corruption issue.
I'm at a loss to explain why. Any ideas?