loading and executing programs

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
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

loading and executing programs

Post by System123 »

I am at the stage where I want my OS to load and execute a program, however I am not sure how to implement this. I know what has to be done but I don't know where to start.
Gizmic OS
Currently - Busy with FAT12 driver and VFS
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: loading and executing programs

Post by JamesM »

Without sounding patronising, firstly you need to load the program, then you need to execute it.

To load a program you will need a filesystem layer and a driver or two to interact with the physical media.

To execute a program you will need a parser for the file format of your choice (ELF, PE, COFF, binary, etc), a virtual memory manager and (possibly) a system call layer.

If you need more specific information you're really going to have to be more specific in your question!
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: loading and executing programs

Post by System123 »

Ok I know that the app must be loaded into memory. It then needs to have the header files read which will then start execution. I am creating my Floppy Device driver to search and load the file into memory. The problem is I don't know if I can load the file anywhere in memory? The other thing is that once it is loaded how do I read the header file, like can I get an example of what it looks like for a PE file.
Gizmic OS
Currently - Busy with FAT12 driver and VFS
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: loading and executing programs

Post by AJ »

Hi,

First Google Hit for PE Specification
First Google Hit for ELF Specification

Your OS can either specify that an executable must be linked at a certain address (or address range) or can use position independent code / relocation. The memory layout of your OS is something that you surely design fairly early on, though?

Later, you may want to look at lazy loading for your executables.

Cheers,
Adam
Post Reply