diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2020-05-14 08:14:44 +0800 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-23 07:55:29 -0400 |
commit | dff1cb3d9c111808fec60190747272b973547c52 (patch) | |
tree | 5abbeff46f069551d448fdf37f87ee4c0e31bc72 /rts/linker/SymbolExtras.c | |
parent | 7f44df1ec6df2b02be83e41cec4dc3b5f7f540f0 (diff) | |
download | haskell-dff1cb3d9c111808fec60190747272b973547c52.tar.gz |
[linker] Fix out of range relocations.
mmap may return address all over the place. mmap_next will ensure we get
the next free page after the requested address.
This is especially important for linking on aarch64, where the memory model with PIC
admits relocations in the +-4GB range, and as such we can't work with
arbitrary object locations in memory.
Of note: we map the rts into process space, so any mapped objects must
not be ouside of the 4GB from the processes address space.
Diffstat (limited to 'rts/linker/SymbolExtras.c')
-rw-r--r-- | rts/linker/SymbolExtras.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/rts/linker/SymbolExtras.c b/rts/linker/SymbolExtras.c index b7b558cb41..b5a06c662c 100644 --- a/rts/linker/SymbolExtras.c +++ b/rts/linker/SymbolExtras.c @@ -79,7 +79,7 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) size_t n = roundUpToPage(oc->fileSize); bssSize = roundUpToAlign(bssSize, 8); size_t allocated_size = n + bssSize + extras_size; - void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); + void *new = mmapForLinker(allocated_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { |