fix order of fini_array execution for shared libs

This commit is contained in:
Rich Felker 2013-07-21 02:35:46 -04:00
parent e69ae844dc
commit 1b413572b2

View File

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