diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /rts/linker/SymbolExtras.c | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'rts/linker/SymbolExtras.c')
-rw-r--r-- | rts/linker/SymbolExtras.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/rts/linker/SymbolExtras.c b/rts/linker/SymbolExtras.c index 486fa4a572..88541f44d0 100644 --- a/rts/linker/SymbolExtras.c +++ b/rts/linker/SymbolExtras.c @@ -51,8 +51,9 @@ int ocAllocateSymbolExtras( ObjectCode* oc, int count, int first ) n = roundUpToPage(oc->fileSize); /* Keep image and symbol_extras contiguous */ - void *new = mmapForLinker(n + (sizeof(SymbolExtra) * count), - MAP_ANONYMOUS, -1, 0); + + size_t allocated_size = n + (sizeof(SymbolExtra) * count); + void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { @@ -62,6 +63,9 @@ int ocAllocateSymbolExtras( ObjectCode* oc, int count, int first ) oc->imageMapped = true; oc->fileSize = n + (sizeof(SymbolExtra) * count); oc->symbol_extras = (SymbolExtra *) (oc->image + n); + if(mprotect(new, allocated_size, PROT_READ | PROT_EXEC) != 0) { + sysErrorBelch("unable to protect memory"); + } } else { oc->symbol_extras = NULL; |