Skip to content

Commit 60c297c

Browse files
committed
Add windows R_X86_64_PC64 relocation support
1 parent deeec55 commit 60c297c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

overlays/bootstrap.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ in {
183183
++ fromUntil "8.6.5" "9.5" ./patches/ghc/ghc-hpc-response-files.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8194
184184
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.4.5" ./patches/ghc/ghc-9.4-hadrian-win-cross.patch)
185185
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.8.1" "9.10" ./patches/ghc/ghc-9.8-hadrian-win-cross.patch)
186+
# support R_X86_64_PC64 (ELF constant 24) - IMAGE_REL_AMD64_SREL32 (PE constant 14), which seems to appear with 9.6 more frequently, and
187+
# results in "unhandled PEi386 relocation type 14".
188+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.10" ./patches/ghc/win-reloc-x86_64-pc64.patch)
186189
++ fromUntil "9.4.5" "9.4.6" ./patches/ghc/ghc-9.4.5-include-order-fix.patch
187190
++ fromUntil "9.6.2" "9.8" ./patches/ghc/ghc-9.4.5-include-order-fix.patch
188191
++ fromUntil "9.6.1" "9.10" ./patches/ghc/MR10116.patch
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
2+
index 0b328df..c404992 100644
3+
--- a/rts/linker/PEi386.c
4+
+++ b/rts/linker/PEi386.c
5+
@@ -2071,6 +2071,15 @@ ocResolve_PEi386 ( ObjectCode* oc )
6+
*(uint32_t *)pP = (uint32_t)v;
7+
break;
8+
}
9+
+ case 14: /* R_X86_64_PC64 (ELF constant 24) - IMAGE_REL_AMD64_SREL32 (PE constant 14) */
10+
+ {
11+
+ /* mingw will emit this for a pc-rel 64 relocation */
12+
+ uint64_t A;
13+
+ checkProddableBlock(oc, pP, 8);
14+
+ A = *(uint64_t*)pP;
15+
+ *(uint64_t *)pP = S + A - (intptr_t)pP;
16+
+ break;
17+
+ }
18+
case 4: /* R_X86_64_PC32 (ELF constant 2) - IMAGE_REL_AMD64_REL32 (PE constant 4) */
19+
{
20+
intptr_t v;

0 commit comments

Comments
 (0)