executable

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
guest

executable

Post by guest »

Hi,
i want to run a very simple application on my OS, how to compile that binary file, i tried to load com file into the memory and jmp where i loaded that file in the memory, but i got errors like running in bogus memory. maybe it is not even a proper way to do this.

any help appreciated, thank you in advance
Therx

Re:executable

Post by Therx »

If you're using flat binary then the app has to be linked to memory location that it's loaded at.

Pete
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:executable

Post by Pype.Clicker »

just loading the application at a location X and jumping to X is not enough to have it run correctly ... remember the application has references to its internal variable and functions and those references will be sensitive to the address at which the application is loaded.

Thus, you can.
a. assume at compile-time that the application will be loaded at X and write an application that will do so. This is especially useful when you have multiprogrammed environment, because every app. has its own address space and therefore can be loaded at a well-known address.

b. keep relocation information in your program and relocate it when you load it. If it's loaded at Y instead of X, you'll be patching every memory reference by adding Y-X... fortunately, most compilers will provide of such locations that need patching.

c. assume the application will get its own data and code segments and that it starts at offset 0 in these segments. when running the application you'll be jumping application_code_selector:0 rather than X (but the base of application_code and application_data has been set to X by the loader).
guest

Re:executable

Post by guest »

and if i want to do it through TSS ?
BI lazy

Re:executable

Post by BI lazy »

Hm. You have to fill in the tss with the correct values before you drop it to the cpu's feet.

the more, the tss is for keeping TASK STATES (as it name indicates - and hopefully I deduce the correct word frm your abbreviation). It won't help you an inch forward to loading a process.

I suggest you scan throu' the section .:QuickLinkz:. There are several *very good* ressources you will find useful.
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:executable

Post by Pype.Clicker »

the "linker & loaders" book (avl. online) is of course a must in that area ...
Post Reply