[commit: ghc] master: Linker: Reenable Thumb support (b62215d)

git at git.haskell.org git at git.haskell.org
Sun Dec 27 00:42:38 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b62215d822d69926798e6cff2fd162ae87adb36d/ghc

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

commit b62215d822d69926798e6cff2fd162ae87adb36d
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sat Dec 26 13:32:56 2015 +0100

    Linker: Reenable Thumb support
    
    I believe this ought to be okay now since we only produce ARM-encoded
    objects. Added a Note describing the state of things.


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

b62215d822d69926798e6cff2fd162ae87adb36d
 rts/Linker.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index 9905d7d..e411e4d 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -326,6 +326,30 @@ static void m32_allocator_init(struct m32_allocator_t *m32);
 #endif
 
 /*
+  Note [The ARM/Thumb Story]
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+  Support for the ARM architecture is complicated by the fact that ARM has not
+  one but several instruction encodings. The two relevant ones here are the original
+  ARM encoding and Thumb, a more dense variant of ARM supporting only a subset
+  of the instruction set.
+
+  How the CPU decodes a particular instruction is determined by a mode bit. This
+  mode bit is set on jump instructions, the value being determined by the low
+  bit of the target address: An odd address means the target is a procedure
+  encoded in the Thumb encoding whereas an even address means it's a traditional
+  ARM procedure (the actual address jumped to is even regardless of the encoding bit).
+
+  Interoperation between Thumb- and ARM-encoded object code (known as "interworking")
+  is tricky. If the linker needs to link a call by an ARM object into Thumb code
+  (or vice-versa) it will produce a jump island. This, however, is incompatible with
+  GHC's tables-next-to-code. For this reason, it is critical that GHC emit
+  exclusively ARM or Thumb objects for all Haskell code.
+
+  We still do, however, need to worry about foreign code.
+*/
+
+/*
  * Due to the small memory model (see above), on x86_64 we have to map
  * all our non-PIC object files into the low 2Gb of the address space
  * (why 2Gb and not 4Gb?  Because all addresses must be reachable
@@ -5023,10 +5047,6 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC,
          // Thumb instructions have bit 0 of symbol's st_value set
          is_target_thm = S & 0x1;
 
-         if (is_target_thm)
-            errorBelch( "Symbol `%s' requires Thumb linkage which is not "
-                        "currently supported.\n", symbol );
-
          T = sym.st_info & STT_FUNC && is_target_thm;
 
          // Make sure we clear bit 0. Strictly speaking we should have done



More information about the ghc-commits mailing list