I finally finished debugging and writing my elf loader.
I loaded some elf binaries, and elf loader works good.
Then I wanted to load an elf binary compiled with my OS-Specific toolchain (i686-agola-gcc)
Then... Bam... Got a pagefault with faulting address 0xFF0AF300
Then started to debugging my crt0.c
After some debugging, I found exit(ex) causes the pagefault. Using _exit instead of exit() solves problem, except exit is more correct and elegant, because of also "does two kinds of cleanup before _exit" (from exit.c, newlib)
That is my crt0.c:
Code: Select all
#include <fcntl.h>
extern int main ();
extern void exit(int code);
extern void _init();
extern void _init_signal();
void _start() {
_init();
_init_signal();
int ex = main();
exit(ex); //Page fault, fault happens while executing memory, non-present page, usually in 0xFF0AF300
}
Thanks