summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2021-02-18 21:16:25 +0000
committerMoritz Angermann <moritz.angermann@gmail.com>2021-03-26 16:49:31 +0800
commit94214f6fc97aa79337230de20759e71f3eb3c25d (patch)
treed7bd4a7f7103b79d2f8d7ec59fffff9176e8a2cb
parent36db1f90dcdc09d5726bbea4fe682fce3c90ee30 (diff)
downloadhaskell-94214f6fc97aa79337230de20759e71f3eb3c25d.tar.gz
linker: Fix atexit handlers on PE
-rw-r--r--rts/Linker.c3
-rw-r--r--rts/linker/PEi386.c5
2 files changed, 5 insertions, 3 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 70738f5ee4..dc4e27cbc0 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -509,9 +509,6 @@ initLinker_ (int retain_cafs)
void
exitLinker( void ) {
-#if defined(OBJFORMAT_PEi386)
- exitLinker_PEi386();
-#endif
#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO)
if (linker_init_done == 1) {
regfree(&re_invalid);
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 80a8ec78ff..c73d858d52 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -327,6 +327,11 @@ void initLinker_PEi386()
HeapSetInformation(code_heap, HeapEnableTerminationOnCorruption,
&HeapInformation, sizeof(HeapInformation));
HeapSetInformation(code_heap, HeapOptimizeResources, NULL, 0);
+
+ /* Register the cleanup routine as an exit handler, this gives other exit handlers
+ a chance to run which may need linker information. Exit handlers are ran in
+ reverse registration order so this needs to be before the linker loads anything. */
+ atexit (exitLinker_PEi386);
}
void exitLinker_PEi386()