Page 1 of 1
C program creation on my OS
Posted: Thu Dec 18, 2003 3:26 am
by Thunder
Hello there,
well, let say that I have created syscalls truth int, and then I have created a stdcalls.h where all call protopypes created. But what start address do I have to create for app, in asm I don't need to create but in c? Because for a kernel I had to have create base address at 0x100000. Or do I have to create separate LDT for every app that starts? Any suggestions?
Bye
Re:C program creation on my OS
Posted: Thu Dec 18, 2003 3:57 am
by Pype.Clicker
Basically, you need to define the programming model (or the execution environment) in which your program will run. I will not try to tell you what you should do as it may depend on what you plan to do, but here come a few hints on what your environment might look like:
- .COM-like environment: your program is given its very own code segment (either in GDT or LDT, depending on how much 'programs' you'd like to have in the same address space). The first page (program address 0-0xfff) should be invalid so that you can trap null pointers and report them. The program is linked so that it starts at virtual address 0x1000. Enforcing the code to be located first allow you to prevent the execution of non-code stuff.
- unix-like environment: each program runs in its very own address-space and is linked to a well-known virtual address (0x800000). Code and Data segments map the whole address space identically and paging prevents access to uncharted areas.
You don't need program-specific segment: everyone may use the same GDT-hosted segments as everyone will use 0-based 4GB limit code and data segments.
- plugin-like environment: the system will decide where the program should run and the program should be adapted to its target location. This is usually achieved either by a relocation list or by position-independent code and global function tables.