diff options
Diffstat (limited to 'rts/linker/MachO.c')
-rw-r--r-- | rts/linker/MachO.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c index c6a6c28440..ca5befca77 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 @@ -182,19 +187,22 @@ resolveImports( #if defined(x86_64_HOST_ARCH) || defined(aarch64_HOST_ARCH) int -ocAllocateSymbolExtras_MachO(ObjectCode* oc) +ocAllocateExtras_MachO(ObjectCode* oc) { - IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_MachO: start\n")); + IF_DEBUG(linker, debugBelch("ocAllocateExtras_MachO: start\n")); if (NULL != oc->info->symCmd) { - IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_MachO: allocate %d symbols\n", oc->info->symCmd->nsyms)); - IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_MachO: done\n")); - return ocAllocateSymbolExtras(oc, oc->info->symCmd->nsyms, 0); + IF_DEBUG(linker, + debugBelch("ocAllocateExtras_MachO: allocate %d symbols\n", + oc->info->symCmd->nsyms)); + IF_DEBUG(linker, debugBelch("ocAllocateExtras_MachO: done\n")); + return ocAllocateExtras(oc, oc->info->symCmd->nsyms, 0, 0); } - IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_MachO: allocated no symbols\n")); - IF_DEBUG(linker, debugBelch("ocAllocateSymbolExtras_MachO: done\n")); - return ocAllocateSymbolExtras(oc,0,0); + IF_DEBUG(linker, + debugBelch("ocAllocateExtras_MachO: allocated no symbols\n")); + IF_DEBUG(linker, debugBelch("ocAllocateExtras_MachO: done\n")); + return ocAllocateExtras(oc, 0, 0, 0); } #else |