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

The hoops they had to go through to get PIC address calculations to work make it quite weird. Because `auipc` adds an offset from its `pc`, the corresponding `add` or `lw` relocation needs refer back to that instruction rather than the symbol it's actually looking for.

The poor ELF specification ends up quite tortured by this, IMO.




That affects ELF relocations but not the code.

Arm64 is even worse! There is almost exactly the same instruction, but it also zeroes the low bits of the target address, so as you relocate code you also have to change the offset in the 2nd instruction even if the distance between the reference and the target stays the same.




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

Search: