Dear all,

The attached patch adds the last little bit for GHC to work properly under
DragonflyBSD. Many thanks also to Goetz Isenmann who made available the
compiler that allowed me to bootstrap.

Markus
-- 
Markus Pfeiffer, University of St Andrews
email: [email protected] | xmpp: [email protected]
From 9d6398bdc02f82c021554cb841fa9dd55d6d3404 Mon Sep 17 00:00:00 2001
From: Markus Pfeiffer <[email protected]>
Date: Wed, 11 Jul 2012 14:59:18 +0000
Subject: [PATCH] rts/Linker.c add X86_64_GOTTPOFF relocation for errno on
 DragonflyBSD

---
 rts/Linker.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index 703bc5f..d25748e 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -121,6 +121,10 @@
 #define ALWAYS_PIC
 #endif
 
+#if defined(dragonfly_HOST_OS)
+#include <sys/tls.h>
+#endif
+
 /* Hash table mapping symbol names to Symbol */
 static /*Str*/HashTable *symhash;
 
@@ -5173,6 +5177,27 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
           *(Elf64_Word *)P = (Elf64_Word)off;
           break;
       }
+#if defined(dragonfly_HOST_OS)
+      case R_X86_64_GOTTPOFF:
+      {
+#if defined(ALWAYS_PIC)
+          barf("R_X86_64_GOTTPOFF relocation, but ALWAYS_PIC.");
+#else
+        /* determine the offset of S to the current thread's tls
+           area 
+           XXX: Move this to the beginning of function */
+          struct tls_info ti;
+          get_tls_area(0, &ti, sizeof(ti));
+          /* make entry in GOT that contains said offset */
+          StgInt64 gotEntry = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), 
+                                         (S - (Elf64_Addr)(ti.base)))->addr;
+          *(Elf64_Word *)P = gotEntry + A - P;
+#endif
+          break;
+      }
+#endif
+
+
 
       case R_X86_64_PLT32:
       {
-- 
1.7.7.2

Attachment: pgpW1uVnYi5ZP.pgp
Description: PGP signature

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to