[commit: ghc] ghc-7.10: rts/linker: ignore unknown PE sections (ad62865)

git at git.haskell.org git at git.haskell.org
Mon Feb 23 09:54:12 UTC 2015


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

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/ad628657cd56362964d17677728f4ae4d6868613/ghc

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

commit ad628657cd56362964d17677728f4ae4d6868613
Author: Tamar Christina <tamar at zhox.com>
Date:   Mon Feb 23 03:40:43 2015 -0600

    rts/linker: ignore unknown PE sections
    
    Summary: Currently the linker tries to see if it understands/knows every section in the PE file before it continues. If it encounters a section it doesn't know about it errors out. Every time there's a change in MinGW compiler that adds a new section to the PE file this will break the ghc linker. The new sections don't need to be understood by `ghc` to continue so instead of erroring out the section is just ignored. When running with `-debug` the sections that are ignored will be printed.
    
    Test Plan:
    See the file `ghcilinkerbug.zip` in #9907.
    
     1) unzip file content.
     2) open examplecpp.cabal and change base <4.8 to <4.9.
     3) execute cabal file with cabal repl.
    
    Applying the patch makes `cabal repl` in step 3) work.
    
    Note that the file will fail on a `___mingw_vprintf` not being found. This is because of the `cc-options` specifying `-std=c++0x`, which will also require `libmingwex.a` to be linked in but wasn't specified in the cabal file. To fix this, remove the `cc-options` which defaults to c99.
    
    Reviewers: austin
    
    Reviewed By: austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D671
    
    GHC Trac Issues: #9907, #7103, #10051, #7056, #8546
    
    (cherry picked from commit a293925d810229fbea77d95f2b3068e78f8380cc)


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

ad628657cd56362964d17677728f4ae4d6868613
 rts/Linker.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index 2ba84f8..0bd2aa8 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -4008,7 +4008,7 @@ lookupSymbolInDLLs ( UChar *lbl )
     void *sym;
 
     for (o_dll = opened_dlls; o_dll != NULL; o_dll = o_dll->next) {
-        /* debugBelch("look in %s for %s\n", o_dll->name, lbl); */
+        /* debugBelch("look in %ls for %s\n", o_dll->name, lbl); */
 
         if (lbl[0] == '_') {
             /* HACK: if the name has an initial underscore, try stripping
@@ -4401,9 +4401,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
           /* ignore linker directive sections */
           && 0 != strcmp(".drectve", (char*)secname)
          ) {
-         errorBelch("Unknown PEi386 section name `%s' (while processing: %" PATH_FMT")", secname, oc->fileName);
-         stgFree(secname);
-         return 0;
+          IF_DEBUG(linker, debugBelch("Unknown PEi386 section name `%s' (while processing: %" PATH_FMT")", secname, oc->fileName));
       }
 
       if (kind != SECTIONKIND_OTHER && end >= start) {



More information about the ghc-commits mailing list