[commit: ghc] master: Abort when binutils ld is used with dynamic linking on ARM (4ade962)

git at git.haskell.org git at git.haskell.org
Tue Jan 28 14:27:19 UTC 2014


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

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

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

commit 4ade9627608ea0a88450506222bb9afbbcff4294
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Sat Jan 25 13:02:36 2014 -0500

    Abort when binutils ld is used with dynamic linking on ARM
    
    The binutils linker on ARM emits unnecessary R_ARM_COPY relocations
    which breaks tables-next-to-code in dynamically linked modules. This
    check should be more selective but there is currently no released
    version where this bug is fixed.  See
    https://sourceware.org/bugzilla/show_bug.cgi?id=16177 and
    https://ghc.haskell.org/trac/ghc/ticket/4210#comment:29 for details.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


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

4ade9627608ea0a88450506222bb9afbbcff4294
 compiler/main/GHC.hs             |   31 +++++++++++++++++++++++++++++++
 docs/users_guide/7.8.1-notes.xml |    6 ++++++
 2 files changed, 37 insertions(+)

diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 6b2815a..2f878fb 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -295,6 +295,7 @@ import Annotations
 import Module
 import UniqFM
 import Panic
+import Platform
 import Bag              ( unitBag )
 import ErrUtils
 import MonadUtils
@@ -450,12 +451,42 @@ initGhcMonad mb_top_dir
                    ; initStaticOpts
                    ; mySettings <- initSysTools mb_top_dir
                    ; dflags <- initDynFlags (defaultDynFlags mySettings)
+                   ; checkBrokenTablesNextToCode dflags
                    ; setUnsafeGlobalDynFlags dflags
                       -- c.f. DynFlags.parseDynamicFlagsFull, which
                       -- creates DynFlags and sets the UnsafeGlobalDynFlags
                    ; newHscEnv dflags }
        ; setSession env }
 
+-- | The binutils linker on ARM emits unnecessary R_ARM_COPY relocations which
+-- breaks tables-next-to-code in dynamically linked modules. This
+-- check should be more selective but there is currently no released
+-- version where this bug is fixed.
+-- See https://sourceware.org/bugzilla/show_bug.cgi?id=16177 and
+-- https://ghc.haskell.org/trac/ghc/ticket/4210#comment:29
+checkBrokenTablesNextToCode :: MonadIO m => DynFlags -> m ()
+checkBrokenTablesNextToCode dflags
+  = do { broken <- checkBrokenTablesNextToCode' dflags
+       ; when broken
+         $ do { liftIO $ throwIO $ mkApiErr dflags 
+                  (text "Tables-next-to-code not supported on ARM using binutils ld (https://sourceware.org/bugzilla/show_bug.cgi?id=16177)")
+              ; fail "unsupported linker"
+              }
+       }
+
+checkBrokenTablesNextToCode' :: MonadIO m => DynFlags -> m Bool
+checkBrokenTablesNextToCode' dflags
+  | not (isARM arch)              = return False
+  | WayDyn `notElem` ways dflags  = return False
+  | not (tablesNextToCode dflags) = return False
+  | otherwise                     = do
+    linkerInfo <- liftIO $ getLinkerInfo dflags
+    case linkerInfo of
+      GnuLD _  -> return True
+      _        -> return False
+  where platform = targetPlatform dflags
+        arch = platformArch platform
+
 
 -- %************************************************************************
 -- %*                                                                      *
diff --git a/docs/users_guide/7.8.1-notes.xml b/docs/users_guide/7.8.1-notes.xml
index ff80fcc..a4fe520 100644
--- a/docs/users_guide/7.8.1-notes.xml
+++ b/docs/users_guide/7.8.1-notes.xml
@@ -365,6 +365,12 @@
                 (e.g. GHCi) support for architectures without support in
                 GHC's own runtime linker (e.g. ARM).
            </para>
+           <para>
+                Note: Tables-next-to-code is disabled when building on
+                ARM with binutil's ld due to a
+                <ulink url="https://sourceware.org/bugzilla/show_bug.cgi?id=16177">
+                bug</ulink> in ld.
+           </para>
        </listitem>
    </itemizedlist>
   </sect2>



More information about the ghc-commits mailing list