fix order of fini_array execution for shared libs
authorRich Felker <dalias@aerifal.cx>
Sun, 21 Jul 2013 06:35:46 +0000 (02:35 -0400)
committerRich Felker <dalias@aerifal.cx>
Sun, 21 Jul 2013 06:35:46 +0000 (02:35 -0400)
src/ldso/dynlink.c

index dbf404ef2dcefef43d76dd7883921f96f915b308..829696ffe29b0c211995991f8b286f242ba5347e 100644 (file)
@@ -698,8 +698,8 @@ static void do_fini()
                decode_vec(p->dynv, dyn, DYN_CNT);
                if (dyn[0] & (1<<DT_FINI_ARRAY)) {
                        size_t n = dyn[DT_FINI_ARRAYSZ]/sizeof(size_t);
-                       size_t *fn = (void *)(p->base + dyn[DT_FINI_ARRAY]);
-                       while (n--) ((void (*)(void))*fn++)();
+                       size_t *fn = (size_t *)(p->base + dyn[DT_FINI_ARRAY])+n;
+                       while (n--) ((void (*)(void))*--fn)();
                }
                if (dyn[0] & (1<<DT_FINI))
                        ((void (*)(void))(p->base + dyn[DT_FINI]))();