Skip to content

Commit 8e0974e

Browse files
angermanhamishmack
andauthored
Rela aarch64 none (#1960)
* Better debug info * Add handle aarch64-none rela * Fix patch so it applies and fix ghc 9.x * ifdLevel 0 * ifdLevel 1 * ifdLevel 2 * ifdLevel 3 * ifdLevel 1 * ifdLevel 1 * ifdLevel 2 * ifdLevel 3 --------- Co-authored-by: Hamish Mackenzie <[email protected]>
1 parent a6bec2e commit 8e0974e

5 files changed

+70
-0
lines changed

overlays/bootstrap.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ in {
205205
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAndroid) ./patches/ghc/libc-memory-symbols.patch
206206
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAndroid) ./patches/ghc/android-base-needs-iconv.patch
207207
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.4" && final.stdenv.targetPlatform != final.stdenv.hostPlatform) ./patches/ghc/ghc-make-stage-1-lib-ghc.patch
208+
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-8.10-better-symbol-addr-debug.patch
209+
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-8.10-aarch64-handle-none-rela.patch
210+
++ final.lib.optional (versionAtLeast "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.0-better-symbol-addr-debug.patch
211+
++ final.lib.optional (versionAtLeast "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.0-aarch64-handle-none-rela.patch
208212
;
209213
in ({
210214
ghc865 = final.callPackage ../compiler/ghc (traceWarnOld "8.6" {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/rts/linker/elf_reloc_aarch64.c b/rts/linker/elf_reloc_aarch64.c
2+
index 3137a8e8df..e315166a32 100644
3+
--- a/rts/linker/elf_reloc_aarch64.c
4+
+++ b/rts/linker/elf_reloc_aarch64.c
5+
@@ -324,10 +324,13 @@ relocateObjectCodeAarch64(ObjectCode * oc) {
6+
7+
Elf_Rela *rel = &relaTab->relocations[i];
8+
9+
+ if(ELF64_R_TYPE(rel->r_info) == COMPAT_R_AARCH64_NONE)
10+
+ continue;
11+
+
12+
ElfSymbol *symbol =
13+
findSymbol(oc,
14+
relaTab->sectionHeader->sh_link,
15+
- ELF64_R_SYM((Elf64_Xword)rel->r_info));
16+
+ ELF64_R_SYM(rel->r_info));
17+
18+
assert(0x0 != symbol);
19+
if(0x0 == symbol->addr)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/rts/linker/elf_reloc_aarch64.c b/rts/linker/elf_reloc_aarch64.c
2+
index 0e11585..06b5774 100644
3+
--- a/rts/linker/elf_reloc_aarch64.c
4+
+++ b/rts/linker/elf_reloc_aarch64.c
5+
@@ -330,7 +330,8 @@ relocateObjectCodeAarch64(ObjectCode * oc) {
6+
ELF64_R_SYM((Elf64_Xword)rel->r_info));
7+
8+
assert(0x0 != symbol);
9+
- assert(0x0 != symbol->addr);
10+
+ if(0x0 == symbol->addr)
11+
+ barf("0x0 address for %s + %d of type %d in %s for relocation %d in section %d of kind: %d\n", symbol->name, rel->r_addend, ELF64_R_TYPE((Elf64_Xword)rel->r_info), OC_INFORMATIVE_FILENAME(oc), i, relaTab->targetSectionIndex, oc->sections[relaTab->targetSectionIndex].kind);
12+
13+
/* take explicit addend */
14+
int64_t addend = rel->r_addend;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/rts/linker/elf_reloc_aarch64.c b/rts/linker/elf_reloc_aarch64.c
2+
index 5e349f2839..11ad67aad4 100644
3+
--- a/rts/linker/elf_reloc_aarch64.c
4+
+++ b/rts/linker/elf_reloc_aarch64.c
5+
@@ -319,10 +319,13 @@ relocateObjectCodeAarch64(ObjectCode * oc) {
6+
7+
Elf_Rela *rel = &relaTab->relocations[i];
8+
9+
+ if(ELF64_R_TYPE(rel->r_info) == COMPAT_R_AARCH64_NONE)
10+
+ continue;
11+
+
12+
ElfSymbol *symbol =
13+
findSymbol(oc,
14+
relaTab->sectionHeader->sh_link,
15+
- ELF64_R_SYM((Elf64_Xword)rel->r_info));
16+
+ ELF64_R_SYM(rel->r_info));
17+
18+
CHECK(0x0 != symbol);
19+
if(0x0 == symbol->addr)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/rts/linker/elf_reloc_aarch64.c b/rts/linker/elf_reloc_aarch64.c
2+
index d8c4f8b724..5e349f2839 100644
3+
--- a/rts/linker/elf_reloc_aarch64.c
4+
+++ b/rts/linker/elf_reloc_aarch64.c
5+
@@ -325,7 +325,8 @@ relocateObjectCodeAarch64(ObjectCode * oc) {
6+
ELF64_R_SYM((Elf64_Xword)rel->r_info));
7+
8+
CHECK(0x0 != symbol);
9+
- CHECK(0x0 != symbol->addr);
10+
+ if(0x0 == symbol->addr)
11+
+ barf("0x0 address for %s + %d of type %d in %s for relocation %d in section %d of kind: %d\n", symbol->name, rel->r_addend, ELF64_R_TYPE((Elf64_Xword)rel->r_info), OC_INFORMATIVE_FILENAME(oc), i, relaTab->targetSectionIndex, oc->sections[relaTab->targetSectionIndex].kind);
12+
13+
/* take explicit addend */
14+
int64_t addend = rel->r_addend;

0 commit comments

Comments
 (0)