summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 2ca9014379..5bc46b486d 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -504,9 +504,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 9f13b4ce3d..32efdec471 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()