1Adding support for the R_X86_64_REX_GOTPCRELX relocation type.
2This relocation is treated by the linker the same as the R_X86_64_GOTPCRELX type
3G + GOT + A - P to generate relative offsets to the GOT.
4The REX prefix has no influence in this stage.
5
6This caused breakage when enabling relro/bindnow hardening e.g. in ghcPaclages.vector
7
8Source: https://phabricator.haskell.org/D2303#67070
9diff --git a/rts/Linker.c b/rts/Linker.c
10--- a/rts/Linker.c
11+++ b/rts/Linker.c
12@@ -5681,7 +5681,13 @@
13 *(Elf64_Sword *)P = (Elf64_Sword)value;
14 #endif
15 break;
16-
17+/* These two relocations were introduced in glibc 2.23 and binutils 2.26.
18+ But in order to use them the system which compiles the bindist for GHC needs
19+ to have glibc >= 2.23. So only use them if they're defined. */
20+#if defined(R_X86_64_REX_GOTPCRELX) && defined(R_X86_64_GOTPCRELX)
21+ case R_X86_64_REX_GOTPCRELX:
22+ case R_X86_64_GOTPCRELX:
23+#endif
24 case R_X86_64_GOTPCREL:
25 {
26 StgInt64 gotAddress = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), S)->addr;
27