executable bases

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
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

executable bases

Post by VolTeK »

is there a certain opcode in a file that i can find to tel me where the file will be loaded? where the base should be

example

org 1000h
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: executable bases

Post by pcmattman »

No. That's why there's executable file formats, like ELF.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: executable bases

Post by Troy Martin »

Nope. That's one the points of a relocatable executable file format. Even a simple 2^x byte executable header is perfect for this.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: executable bases

Post by VolTeK »

oh, alright, thanks
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: executable bases

Post by Troy Martin »

What I would suggest is passing the base from the kernel to the program in a register such as DX (or EDX in pmode) so the program can then play with that.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: executable bases

Post by neon »

What I would suggest is passing the base from the kernel to the program in a register such as DX (or EDX in pmode) so the program can then play with that.
I personally dont recommend that. It is hackish imho and creates an unnecessary dependency between the calling program and OS.

If the program is needing to know where it is located at, there are nicer methods of obtaining that information. ie; like the program calling a API function to obtain it.

Just my 2 cents.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: executable bases

Post by salil_bhagurkar »

I think it should be possible (just to prove the concept) by locating an absolute jump/call within the first few instructions of the program. This would require some minimal disassembly of the program. By assuming an alignment of the program in the memory, it should be possible to inaccurately determine the load address..
Post Reply