Basic elf loader

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
beyondsociety

Basic elf loader

Post by beyondsociety »

Im currently trying to get my bootloader to support the loading of elf files.

Basically I have a bootsector that is compiled to binary that loads into pmode and transfers control at 1Mb to a stub file that links together with my c files. I want this stub to be able to load the kernel in elf format from the disk.

I have looked at chris greese's loader in C, but its too complicated for me. Since this will be loaded in the stub, Im going to be writing it in 32-bit assembly. At the moment Im currently getting my help from the linkers and loaders online book and this site: http://www.muppetlabs.com/~breadbox/sof ... eensy.html

Does anybody have any experience with writing one?
Any help would be appreciated.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Basic elf loader

Post by Candy »

beyondsociety wrote: I have looked at chris greese's loader in C, but its too complicated for me. Since this will be loaded in the stub, Im going to be writing it in 32-bit assembly. At the moment Im currently getting my help from the linkers and loaders online book and this site: http://www.muppetlabs.com/~breadbox/sof ... eensy.html

Does anybody have any experience with writing one?
Any help would be appreciated.
You could look at my boot loader, the second stage takes the ELF binary loaded at 0x20000 (which the boot sector loads there) and relocates it as it should be, placing page tables & stuff up, but does not copy the kernel, so the relocated pages still point inside the ELF executable. All segments must be page-aligned also. That's also why it's a very simple ELF loader.

It loads my kernel to 0xF0000000.

HTH, Candy

PS: the kernel can be found in the aurora-release at www.sf.net/projects/atlantisos
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Basic elf loader

Post by Pype.Clicker »

i do not have an ELF 'loader', but i toyed quite alot with ELF binaries in order to convert them into something easier to load.

The 'collected information about ELF' i have is at http://sourceforge.net/docman/display_d ... p_id=10181

My 'ELF-access library' is mainly at http://cvs.sourceforge.net/viewcvs.py/c ... ools/misc/ and http://cvs.sourceforge.net/viewcvs.py/c ... 2/#dirlist
Post Reply