summaryrefslogtreecommitdiff
path: root/rts/linker/MachO.c
diff options
context:
space:
mode:
authorZejun Wu <watashi@fb.com>2018-12-28 20:37:13 -0800
committerBen Gamari <ben@smart-cactus.org>2019-01-30 10:06:32 -0500
commite29b1ee72d77d5a06ac949f9dcc80108243a25c0 (patch)
tree3c2104b52c52d77b130c98d3cd486eb47ed2f347 /rts/linker/MachO.c
parent4bf35da4fccd2a21153a1c19bfa80006e99e02a1 (diff)
downloadhaskell-e29b1ee72d77d5a06ac949f9dcc80108243a25c0.tar.gz
Add a RTS option -xp to load PIC object anywhere in address space
Summary: This re-applies {D5195} with fixes for i386: * Fix unused label warnings, see {D5230} or {D5273} * Fix a silly bug introduced by moving `#if` {P190} Add a RTS option -xp to load PIC object anywhere in address space. We do this by relaxing the requirement of <0x80000000 result of `mmapForLinker` and implying USE_CONTIGUOUS_MMAP. We also need to change calls to `ocInit` and `ocGetNames` to avoid dangling pointers when the address of `oc->image` is changed by `ocAllocateSymbolExtra`. Test Plan: See {D5195}, also test under i386: ``` $ uname -a Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28 20:45:30 CEST 2018 i686 GNU/Linux $ cd testsuite/tests/th/ && make test ... ``` will run `./validate` on stacked diff. Reviewers: simonmar, bgamari, alpmestan, trommler, hvr, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5289
Diffstat (limited to 'rts/linker/MachO.c')
-rw-r--r--rts/linker/MachO.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c
index c6a6c28440..4a1204dde9 100644
--- a/rts/linker/MachO.c
+++ b/rts/linker/MachO.c
@@ -99,6 +99,8 @@ bool ocMprotect_MachO( ObjectCode *oc );
void
ocInit_MachO(ObjectCode * oc)
{
+ ocDeinit_MachO(oc);
+
oc->info = (struct ObjectCodeFormatInfo*)stgCallocBytes(
1, sizeof *oc->info,
"ocInit_MachO(ObjectCodeFormatInfo)");
@@ -160,16 +162,19 @@ ocInit_MachO(ObjectCode * oc)
void
ocDeinit_MachO(ObjectCode * oc) {
- if(oc->info->n_macho_symbols > 0) {
- stgFree(oc->info->macho_symbols);
- }
+ if (oc->info != NULL) {
+ if(oc->info->n_macho_symbols > 0) {
+ stgFree(oc->info->macho_symbols);
+ }
#if defined(aarch64_HOST_ARCH)
- freeGot(oc);
- for(int i = 0; i < oc->n_sections; i++) {
- freeStubs(&oc->sections[i]);
- }
+ freeGot(oc);
+ for(int i = 0; i < oc->n_sections; i++) {
+ freeStubs(&oc->sections[i]);
+ }
#endif
- stgFree(oc->info);
+ stgFree(oc->info);
+ oc->info = NULL;
+ }
}
static int