summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 8c7cc2848a..cd469b4f2d 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1136,6 +1136,16 @@ void freeObjectCode (ObjectCode *oc)
{
IF_DEBUG(linker, ocDebugBelch(oc, "start\n"));
+ // Run finalizers
+ if (oc->type == STATIC_OBJECT &&
+ (oc->status == OBJECT_READY || oc->status == OBJECT_UNLOADED)) {
+ // Only run finalizers if the initializers have also been run, which
+ // happens when we resolve the object.
+#if defined(OBJFORMAT_ELF)
+ ocRunFini_ELF(oc);
+#endif
+ }
+
if (oc->type == DYNAMIC_OBJECT) {
#if defined(OBJFORMAT_ELF)
ACQUIRE_LOCK(&dl_mutex);