summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/linker/Elf.c3
-rw-r--r--rts/linker/InitFini.c5
-rw-r--r--rts/linker/InitFini.h1
3 files changed, 9 insertions, 0 deletions
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c
index 197edc95e3..b6473bb2a8 100644
--- a/rts/linker/Elf.c
+++ b/rts/linker/Elf.c
@@ -719,6 +719,9 @@ ocGetNames_ELF ( ObjectCode* oc )
if (kind == SECTIONKIND_CODE_OR_RODATA
&& 0 == memcmp(".init", sh_name, 5)) {
addInitFini(&oc->info->init, &oc->sections[i], INITFINI_INIT, 0);
+ } else if (kind == SECTIONKIND_CODE_OR_RODATA
+ && 0 == memcmp(".fini", sh_name, 5)) {
+ addInitFini(&oc->info->fini, &oc->sections[i], INITFINI_FINI, 0);
} else if (kind == SECTIONKIND_INIT_ARRAY
|| 0 == memcmp(".init_array", sh_name, 11)) {
uint32_t prio;
diff --git a/rts/linker/InitFini.c b/rts/linker/InitFini.c
index 48a548e3cf..6c787fe552 100644
--- a/rts/linker/InitFini.c
+++ b/rts/linker/InitFini.c
@@ -120,6 +120,11 @@ static bool runInitFini(struct InitFiniList **head)
(*init)(argc, argv, envv);
break;
}
+ case INITFINI_FINI: {
+ fini_t *fini = (fini_t*)section->start;
+ (*fini)();
+ break;
+ }
case INITFINI_CTORS: {
uint8_t *init_startC = section->start;
init_t *init_start = (init_t*)init_startC;
diff --git a/rts/linker/InitFini.h b/rts/linker/InitFini.h
index f00233d88d..c0a044402e 100644
--- a/rts/linker/InitFini.h
+++ b/rts/linker/InitFini.h
@@ -2,6 +2,7 @@
enum InitFiniKind {
INITFINI_INIT, // .init section
+ INITFINI_FINI, // .fini section
INITFINI_CTORS, // .ctors section
INITFINI_DTORS, // .dtors section
INITFINI_INIT_ARRAY, // .init_array section