[Git][ghc/ghc][master] rts: Handle zero-sized mappings in MachO linker

Marge Bot gitlab at gitlab.haskell.org
Thu May 30 11:29:51 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
4ad37a32 by Ben Gamari at 2019-05-30T11:29:47Z
rts: Handle zero-sized mappings in MachO linker

As noted in #16701, it is possible that we will find that an object has
no segments needing to be mapped. Previously this would result in mmap
being called for a zero-length mapping, which would fail. We now simply
skip the mmap call in this case; the rest of the logic just works.

- - - - -


1 changed file:

- rts/linker/MachO.c


Changes:

=====================================
rts/linker/MachO.c
=====================================
@@ -1122,8 +1122,12 @@ ocBuildSegments_MachO(ObjectCode *oc)
         n_activeSegments++;
     }
 
-    mem = mmapForLinker(size_compound, MAP_ANON, -1, 0);
-    if (NULL == mem) return 0;
+    // N.B. it's possible that there is nothing mappable in an object. In this
+    // case we avoid the mmap call since it would fail. See #16701.
+    if (size_compound > 0) {
+        mem = mmapForLinker(size_compound, MAP_ANON, -1, 0);
+        if (NULL == mem) return 0;
+    }
 
     IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments));
     segments = (Segment*)stgCallocBytes(n_activeSegments, sizeof(Segment),



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/4ad37a323b9cdb830d718dec08c2960e34410a43

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/4ad37a323b9cdb830d718dec08c2960e34410a43
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190530/81a3bff2/attachment-0001.html>


More information about the ghc-commits mailing list