[commit: ghc] wip/aarch64-regd: WIP (65408af)

git at git.haskell.org git at git.haskell.org
Sun Oct 25 03:29:16 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/aarch64-regd
Link       : http://ghc.haskell.org/trac/ghc/changeset/65408af7520af75f72c8151b6dd900acffeefbcf/ghc

>---------------------------------------------------------------

commit 65408af7520af75f72c8151b6dd900acffeefbcf
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date:   Fri Oct 23 18:22:27 2015 +1100

    WIP


>---------------------------------------------------------------

65408af7520af75f72c8151b6dd900acffeefbcf
 rts/Linker.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index ae3c72e..31e8324 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -6522,8 +6522,22 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
           break;
 
 	case R_AARCH64_ADR_PREL_PG_HI21:
-            puts ("AArch64: unhandled ELF relocation(RelA) R_AARCH64_ADR_PREL_PG_HI21");
-            break;
+          puts ("AArch64: unhandled ELF relocation(RelA) R_AARCH64_ADR_PREL_PG_HI21");
+		  {
+            // Operation: Page(S+A) - Page(P)
+            uint64_t Result = ((S + A) & ~0xfffULL) - (FinalAddress & ~0xfffULL);
+
+            // Check that -2^32 <= X < 2^32
+            if (Result >> 32)
+                 barf ("%s: overflow check failed for relocation", oc->fileName);
+
+            *(Elf64_Xword *)P &= 0x9f00001fU;
+            // Immediate goes in bits 30:29 + 5:23 of ADRP instruction, taken
+            // from bits 32:12 of X.
+            *(Elf64_Xword *)P |= ((Result & 0x3000U) << (29 - 12));
+            *(Elf64_Xword *)P |= ((Result & 0x1ffffc000ULL) >> (14 - 5));
+          }
+          break;
 
 
          default:



More information about the ghc-commits mailing list