2013-09-05

2013-09-05 Loading ELFs (Elves?)

So I copied the ELF loader from a previous kernel into this one, compile errors akimbo because it was already there, n00b!

The previous loader loaded the ELF binary and maintained a symbol table so that I could resolve library symbols.  Because I want it to load executables, I added a wrapper function to load the ELF binary as a library, then call the entry point, then free the memory.  It's crude, but it'll demonstrate loading the elf file.

First attempt threw an interrupt 13 (general protection fault), which is odd as there shouldn't be any protection on the memory (and my code should all work first time anyway).  This showed two problems, malloc() returned 0 (which I wasn't trapping) and I hadn't loaded the GDT so it was running with whatever GRUB loaded.

Got the GDT loading code from the earlier kernel ("DriveAccess") and got that part fixed.

Now back to the malloc.  Oh, wait, maybe I should use the kmalloc(), rather than the unimplemented libc malloc() (which is hard-coded to return 0 currently) ... sad face.

Ok, stupid errors fixed up, it claims to be loading the ELF file ...

No comments:

Post a Comment