Segmentation Fault
Posted: Fri Dec 11, 2020 2:24 pm
HI, all the best for you
I'm trying to compile the code from /klange/toaruos in windows environment.
All code is in https://github.com/zecarlos1957/learnos in develop branch.
I started with a small piece of code to which i was adding functions
and now i can compile the kernel without errors after making some changes
to satisfy my compiler that is MinGW32-gcc.
Now the problems arise.
After compiling the kernel and modules for pei-i386, I used <objcopy -O elf32-i386 ...> so that grub/stage2_eltorito recognizes the format.
After loading the kernel and the <vgadbg.ko> module and relocating all addresses, in <module.c: module_load_direct (...)>, and within the function "vgadbg_init ()" of this module, calls to global functions "create_kernel_tasklet (...)", "memset (...)" and sprintf (...) fail with "Segmentation Fault"
Consulting the memory map of the linker, I created pointers for these functions, and it turns out that by making calls through these, they occurred successfully.
Also when I make the call using the function name, the relocation to this reference appears with type R_386_PC32.
Can anyone help solving this problem?
Thank you so much.
I'm trying to compile the code from /klange/toaruos in windows environment.
All code is in https://github.com/zecarlos1957/learnos in develop branch.
I started with a small piece of code to which i was adding functions
and now i can compile the kernel without errors after making some changes
to satisfy my compiler that is MinGW32-gcc.
Now the problems arise.
After compiling the kernel and modules for pei-i386, I used <objcopy -O elf32-i386 ...> so that grub/stage2_eltorito recognizes the format.
After loading the kernel and the <vgadbg.ko> module and relocating all addresses, in <module.c: module_load_direct (...)>, and within the function "vgadbg_init ()" of this module, calls to global functions "create_kernel_tasklet (...)", "memset (...)" and sprintf (...) fail with "Segmentation Fault"
Consulting the memory map of the linker, I created pointers for these functions, and it turns out that by making calls through these, they occurred successfully.
Also when I make the call using the function name, the relocation to this reference appears with type R_386_PC32.
Can anyone help solving this problem?
Code: Select all
typedef int (*func)(tasklet_t tasklet, char * name, void * argp);
typedef int(*sprt)(char*, const char*, ...);
static int vgadbg_init(void)
{
char buf[128];
sprt sprint = (sprt)0x10cd92;
// memset(textmemptr, 0x00, sizeof(unsigned short) * 80 * 25);
write_string("VGA Text-Mode Debugger\n");
write_string(" If you're seeing this, module loading completed successfully.\n");
write_string(" We'll now do some checks to see what may be wrong with the system.\n");
sprint(buf,"Addr %x\n",(uint32_t)&create_kernel_tasklet);
write_string(buf);
func f1 = create_kernel_tasklet;
f1(tasklet, "[[vgadbg]]", NULL);
/// create_kernel_tasklet(tasklet, "[[vgadbg]]", NULL); -> SEGMENTATION FAULT
return 0;
}