[Git][ghc/ghc][wip/T16779] rts/linker: Only mprotect GOT after it is filled

Ben Gamari gitlab at gitlab.haskell.org
Sat Jun 8 18:19:31 UTC 2019



Ben Gamari pushed to branch wip/T16779 at Glasgow Haskell Compiler / GHC


Commits:
47b6011e by Ben Gamari at 2019-06-08T18:19:21Z
rts/linker: Only mprotect GOT after it is filled

This fixes a regression, introduced by 67c422ca, where we mprotect'd the
global offset table (GOT) region to PROT_READ before we had finished
filling it, resulting in a linker crash.

Fixes #16779.

- - - - -


1 changed file:

- rts/linker/elf_got.c


Changes:

=====================================
rts/linker/elf_got.c
=====================================
@@ -64,8 +64,6 @@ makeGot(ObjectCode * oc) {
                     symTab->symbols[i].got_addr
                             = (uint8_t *)oc->info->got_start
                               + (slot++ * sizeof(void*));
-        if(mprotect(mem, oc->info->got_size, PROT_READ) != 0) {
-            sysErrorBelch("unable to protect memory");
         }
     }
     return EXIT_SUCCESS;
@@ -115,6 +113,11 @@ fillGot(ObjectCode * oc) {
             }
         }
     }
+
+    // We are done initializing the GOT; freeze it.
+    if(mprotect(of->info->got_start, oc->info->got_size, PROT_READ) != 0) {
+        sysErrorBelch("unable to protect memory");
+    }
     return EXIT_SUCCESS;
 }
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/47b6011e65e63c65743b8500eca8321034d91fc2

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/47b6011e65e63c65743b8500eca8321034d91fc2
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/20190608/51980873/attachment.html>


More information about the ghc-commits mailing list