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.

(cherry picked from commit 217e6db4)
18 jobs for !1172 with wip/backport-MR1137 in 420 minutes and 53 seconds (queued for 1 second)
detached
Status Job ID Name Coverage
  Lint
passed #100672
lint
ghc-linters

00:00:15

passed #100673
lint
lint-submods-mr

00:00:14

 
  Build
failed #100676
x86_64-linux allowed to fail
release-x86_64-linux-deb9-dwarf

00:00:33

passed #100674
x86_64-linux
validate-x86_64-linux-deb8-hadrian

03:03:30

passed #100675
x86_64-linux
validate-x86_64-linux-deb9-debug

01:15:36

 
  Full Build
failed #100678
aarch64-linux allowed to fail
validate-aarch64-linux-deb9

00:59:26

passed #100679
x86_64-linux
validate-i386-linux-deb9

00:57:10

passed #100677
x86_64-darwin
validate-x86_64-darwin

01:21:44

passed #100680
x86_64-linux
validate-x86_64-linux-deb9

01:42:06

failed #100682
x86_64-linux allowed to fail
validate-x86_64-linux-deb9-integer-simple

00:24:37

failed #100681
x86_64-linux allowed to fail
validate-x86_64-linux-deb9-llvm

02:25:41

passed #100683
x86_64-linux
validate-x86_64-linux-deb9-unreg

02:26:56

passed #100684
x86_64-linux
validate-x86_64-linux-fedora27

01:15:46

failed #100686
x86_64-windows allowed to fail
validate-x86_64-windows

failed #100685
x86_64-windows allowed to fail
validate-x86_64-windows-hadrian

 
  Cleanup
passed #100688
x86_64-darwin
cleanup-darwin

00:00:05

passed #100687
x86_64-windows
cleanup-windows

00:00:25

 
  Hackage
manual #100689
x86_64-linux allowed to fail manual
hackage
 
Name Stage Failure
failed
validate-aarch64-linux-deb9 Full Build
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
WARNING: ghc-*.tar.xz: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows-hadrian Full Build There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job log
failed
release-x86_64-linux-deb9-dwarf Build
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
WARNING: ghc-*.tar.xz: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
validate-x86_64-linux-deb9-integer-simple Full Build
make[1]: *** Waiting for unfinished jobs....
Makefile:123: recipe for target 'all' failed
make: *** [all] Error 2
Running after script...
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows Full Build There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job log
failed
validate-x86_64-linux-deb9-llvm Full Build
make[1]: *** [test] Error 1
Makefile:224: recipe for target 'test' failed
make: *** [test] Error 2
Running after script...
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
junit.xml: found 1 matching files
Uploading artifacts to coordinator... ok
id=100681 responseStatus=201 Created token=CQghahM6
ERROR: Job failed: exit code 1