Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

but for x86_64, as of right now, if only a single call needs more than 31bits you have to upgrade the whole code section to large code model.

BOLT AFAIU is more about cache locality of putting hot code near each other and not really breaking the 2GiB barrier.





Why? Can't the linker or post-link optimizer reduce all near calls, leaving the more complicated mov with immediate form only where required?

Once the compiler has generated a 32-bit relative jump with an R_X86_64_PLT32 relocation, it’s too late. (A bit surprising for it to be a PLT relocation, but it does make some sense upon reflection, and the linker turns it into a direct call if you’re statically linking.) I think only RISC-V was brave enough to allow potentially size-changing linker relaxation, and incidentally they screwed it up (the bug tracker says “too late to change”, which brings me great sadness given we’re talking about a new platform).

On x86-64 it would probably be easier to point the relative call to a synthesized trampoline that does a 64-bit one, but it seems nobody has bothered thus far. You have to admit that sounds pretty painful.




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

Search: