summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-08 13:28:19 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-12 07:36:36 -0400
commit217e6db4af6752b13c586d4e8925a4a9a2f47245 (patch)
tree150c3c9e1387bcfa5f8893cd1630dc1a97231714
parentbbc752c50f3adcb659cd8447635828e137a0a314 (diff)
downloadhaskell-217e6db4af6752b13c586d4e8925a4a9a2f47245.tar.gz
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.
-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;
}