diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-11-18 11:40:29 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-11-30 18:56:35 -0500 |
commit | 4b83b6a8f8ac08e81b6e75c47f133e3ed6bdea95 (patch) | |
tree | cbe3c0b84ac2c139d06c98f513f9d262263140fe | |
parent | 7da4e5882e9f3f91201d7eda02c44883e1e89435 (diff) | |
download | haskell-4b83b6a8f8ac08e81b6e75c47f133e3ed6bdea95.tar.gz |
rts/linker: Align bssSize to page size when mapping symbol extras
We place symbol_extras right after bss. We also need
to ensure that symbol_extras can be mprotect'd independently from the
rest of the image. To ensure this we round up the size of bss to a page
boundary, thus ensuring that symbol_extras is also page-aligned.
(cherry picked from commit 9f40cf6ca9fb24dbc55f7eae43e2b89aa12bf251)
-rw-r--r-- | rts/linker/SymbolExtras.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/rts/linker/SymbolExtras.c b/rts/linker/SymbolExtras.c index b7b558cb41..f42f5dd07c 100644 --- a/rts/linker/SymbolExtras.c +++ b/rts/linker/SymbolExtras.c @@ -77,7 +77,9 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) /* N.B. We currently can't mark symbol extras as non-executable in this * case. */ size_t n = roundUpToPage(oc->fileSize); - bssSize = roundUpToAlign(bssSize, 8); + // round bssSize up to the nearest page size since we need to ensure that + // symbol_extras is aligned to a page boundary so it can be mprotect'd. + bssSize = roundUpToPage(bssSize); size_t allocated_size = n + bssSize + extras_size; void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); if (new) { |