Skip to content

PE RTS linker should learn how to relax 32-bit absolute relocations to PC-relative relocations

As noted in #18194, we can very easily end up in situations where the PE linker is unable to load code on Windows since we don't compile for PIC. Unfortunately, any long-lived GHCi session on Windows is almost destined to run into this.

While the long-term solution here is to introduce dynamic linking support on Windows, in the short term we can improve the situation by teaching the linker to relax 32-bit absolute relocations (e.g. IMAGE_REL_AMD64_ADDR32) to a PC-relative relocation (e.g. IMAGE_REL_AMD64_REL32). This won't be trivial as it will require that the linker learn to patch up instructions. Nevertheless, @Phyx and I suspect that it shouldn't be that hard to handle the common cases.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information