|
|
Am 19.05.2011 17:55, schrieb Invisible:
> One thing about loading data from file is that you usually don't get to
> decide where it gets loaded. Is that a problem for x86? Is it hard to
> write relocatable machine code or something?
Not really. For jumping around or calling subroutines in your own code
there are CALL and JMP instructions available that take a relative
address as operand; and with rather simple code you can auto-detect the
load address from within your code, so you can also compute absolute
addresses e.g. to access constants, pass callback function pointers to
some API, or use some portion of the code as a global variables space.
For the sake of run-time performance it is faster though to hard-code
such absolute addresses, and have the respective code locations adjusted
accordingly upon loading of the code. AFAIK that's the basic principle
most executable file formats work.
Post a reply to this message
|
|