OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 12:02 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ELF
PostPosted: Sat Mar 23, 2002 6:50 am 
Hi,

I'd like to try to load an ELF binary without using GRUB but all docs I've read have about 1 page about program loading - any hints on this??? Most important would be: order of loaded sections and what sections are important to load and which are not. Maybe something on relocation?

Thanks

Darkening


Top
  
 
 Post subject: Re: ELF
PostPosted: Sat Mar 23, 2002 1:27 pm 
In ELF, there are sections and "segments". Sections denote logical parts of the executable (as code, data etc.) and segments describe what parts of the executable file are what (and, more importantly, which should be loaded). Basically, to run an ELF file, you have to do the following:
1. Read the ELF header and check that it is really an ELF file (and that it is built for your architecture).
2. Read the program headers (list of "segments"), location of which is specified in the ELF header.
3. Load every segment listed in the program headers that is marked loadable (type PT_LOAD).
4. If you load shared libraries along with the executable, remember the address of the dynamic section (the corresponding segment for which is marked PT_DYNAMIC).

If you use shared libraries, you also have to process all the relocations (I spent about two weeks firuring out everything about relocations, but that's not really difficult). Otherwise, there are no relocations.

BTW, are you loading the ELF kernel? If you want, I can mail you the source of my loader, which can load a kernel along with some modules and relocate everything (it is a bit complex, though).


Top
  
 
 Post subject: Re: ELF
PostPosted: Sat Mar 23, 2002 1:29 pm 
BTW, this is the ELF specification. You may want to check it out: http://www.nondot.org/sabre/os/files/Executables/ELF.pdf


Top
  
 
 Post subject: Re: ELF
PostPosted: Sat Mar 30, 2002 2:15 am 
Sorry that I'm replying so late...

@Kernel Panic: Would be great to have a look at your source code! eMail address is [email protected]

Darkening


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 221 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group