Page 1 of 1

executable file format

Posted: Tue Feb 10, 2009 10:10 am
by jtlb
Hi,

In your opinion what executable file format should i shouse for my operating system's shared library? And is there anyone that allows relocating the code just by changing an offset?


EDIT1:
actualy, iam looking for an executable file format which is completly position independent.

Re: executable file format

Posted: Tue Feb 10, 2009 10:54 am
by Solar
Unfortunately that's not up to the executable format, but the CPU instruction set... since the x86 does not support data access relative to the instruction pointer, no matter what the executable format, you need to play some tricks. (In this case, using a register to point to the data.)

Due to the amount of documentation and readily available tools, the "canon" decision is to use ELF. Of course you can chose otherwise, but it's like "use C" or "use GCC".

Re: executable file format

Posted: Tue Feb 10, 2009 11:04 am
by jtlb
OK, it's sad!


Thank you

Re: executable file format

Posted: Tue Feb 10, 2009 8:05 pm
by iammisc
for position independent CODE only, you can use gcc's -fPIC option, but like Solar said, you have to resort to some tricks to let it write to position independent data and to link to shared libraries.

Also, if I'm not mistaken, the amd64 processors have rip relative addressing. I'm pretty sure on could use this for complete position independence, but I'm not sure.

Re: executable file format

Posted: Wed Feb 11, 2009 9:08 am
by JAAman
yes, x86-64 does have IP-reletive addressing, which can do this, but that is only availible in LMode