summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-08 13:28:19 -0400
committerBen Gamari <ben@smart-cactus.org>2019-06-08 15:37:45 -0400
commite04f6328a66361592a60003b8a2e3ea1a6659579 (patch)
treeaee1191c4d29bc967b28ccc6b67ead947196de15
parentded89f5637aea2ede3b4ca18bcb47998a41e1d0d (diff)
downloadhaskell-wip/T16779.tar.gz
rts/linker: Only mprotect GOT after it is filledwip/T16779
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.
-rw-r--r--rts/linker/elf_got.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/rts/linker/elf_got.c b/rts/linker/elf_got.c
index ee73a4a4da..9be2490a17 100644
--- a/rts/linker/elf_got.c
+++ b/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(oc->info->got_start, oc->info->got_size, PROT_READ) != 0) {
+ sysErrorBelch("unable to protect memory");
+ }
return EXIT_SUCCESS;
}