diff options
author | Tamar Christina <tamar@zhox.com> | 2021-02-18 21:16:25 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-04-07 18:37:46 -0400 |
commit | 3b37baaf54cbc0bb10702127a6aef0321202b951 (patch) | |
tree | aa646403c049abe57d51dddc070ca5efadf124f7 | |
parent | 8581d01ab42b2321ec69422392038dff1ceca4b3 (diff) | |
download | haskell-3b37baaf54cbc0bb10702127a6aef0321202b951.tar.gz |
linker: Fix atexit handlers on PE
(cherry picked from commit 54ba8d8a3e810b77ce3df99903b619de8b840c20)
-rw-r--r-- | rts/Linker.c | 3 | ||||
-rw-r--r-- | rts/linker/PEi386.c | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index c03fb5506b..483c76431e 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -491,9 +491,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 33eb0765a6..ec9d5c9080 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() |