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
executable
Re:executable
If you're using flat binary then the app has to be linked to memory location that it's loaded at.
Pete
Pete
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:executable
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).
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).
Re:executable
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.
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.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:executable
the "linker & loaders" book (avl. online) is of course a must in that area ...