summaryrefslogtreecommitdiff
path: root/rts/linker
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2017-08-19 08:31:34 +0100
committerTamar Christina <tamar@zhox.com>2017-08-19 08:31:34 +0100
commitee2e9ece388e75ac433097ac726a555a07ae0830 (patch)
tree512d3860f3f75a5e284785d6cffb49759bc7b3f9 /rts/linker
parent8e5b6ec6566da57d15b0810a07902d9eac85cb79 (diff)
downloadhaskell-ee2e9ece388e75ac433097ac726a555a07ae0830.tar.gz
Correct incorrect free in PE linker
Summary: The big-obj support (D3523) had introduced an early free on the info structure. Because the pointer is not NULL'd and the default of all the utility functions was to the standard object format, it all kept working. The one big-obj test that exists was subjected to a timing issue. usually the test ran quickly enough that the allocator hasn't had time to reclaim the memory yet, so it still passed. This corrects it. Also as it so happens, static LLVM libraries from mingw-w64 are compiled using big-obj. Test Plan: ./validate Reviewers: austin, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13815, #13093 Differential Revision: https://phabricator.haskell.org/D3862
Diffstat (limited to 'rts/linker')
-rw-r--r--rts/linker/PEi386.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 22258fe970..42e700805e 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -1421,6 +1421,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
addr = (char*)cstring_from_COFF_symbol_name(
getSymShortName (info, symtab_i),
strtab);
+ stgFree (info);
IF_DEBUG(linker,
debugBelch("addImportSymbol `%s' => `%s'\n",
@@ -1471,8 +1472,6 @@ ocGetNames_PEi386 ( ObjectCode* oc )
i += getSymNumberOfAuxSymbols (info, symtab_i);
}
- stgFree (info);
-
/* Allocate BSS space */
SymbolAddr* bss = NULL;
if (globalBssSize > 0) {
@@ -1570,6 +1569,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (result != NULL || dllInstance == 0) {
errorBelch("Could not load `%s'. Reason: %s\n",
(char*)dllName, result);
+ stgFree (info);
return false;
}
@@ -1599,8 +1599,10 @@ ocGetNames_PEi386 ( ObjectCode* oc )
sname[size-start]='\0';
stgFree(tmp);
if (!ghciInsertSymbolTable(oc->fileName, symhash, (SymbolName*)sname,
- addr, false, oc))
+ addr, false, oc)) {
+ stgFree (info);
return false;
+ }
break;
}
@@ -1617,6 +1619,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (! ghciInsertSymbolTable(oc->fileName, symhash, (SymbolName*)sname, addr,
isWeak, oc)) {
+ stgFree (info);
return false;
}
} else {
@@ -1650,6 +1653,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
i += getSymNumberOfAuxSymbols (info, symtab_i);
}
+ stgFree (info);
return true;
}