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.
executable file format
Re: executable file format
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".
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".
Every good solution is obvious once you've found it.
Re: executable file format
OK, it's sad!
Thank you
Thank you
Re: executable file format
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.
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
yes, x86-64 does have IP-reletive addressing, which can do this, but that is only availible in LMode