Hacker News new | past | comments | ask | show | jobs | submit login

Modern amd64 code is position-independent, so the JMP address is relative.

On other architectures, it's the linker's job to convert symbolic addresses and it can choose all the addresses in one go as it's the final stage producting the executable.




That solves internal offsets. But code can also be loaded at different addresses on many platforms/architecture combos. That's solved by relocation tables: For every address, the linker will assume a starting address of 0, and then add the location of the address to a table. The runtime linker will then go through the relocation tables and fix up any entries with the real address.


Relative to what, the start address? Does rust determine the start address from the return value of `mmap`?


Relative to the current instruction pointer aka program counter. You say things like "JMP -100 bytes".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: