+static size_t find_dyn(Phdr *ph, size_t cnt, size_t stride)
+{
+ for (; cnt--; ph = (void *)((char *)ph + stride))
+ if (ph->p_type == PT_DYNAMIC)
+ return ph->p_vaddr;
+ return 0;
+}
+
+static void do_init_fini(struct dso *p)
+{
+ size_t dyn[DYN_CNT] = {0};
+ for (; p; p=p->prev) {
+ if (p->constructed) return;
+ decode_vec(p->dynv, dyn, DYN_CNT);
+ if (dyn[0] & (1<<DT_FINI))
+ atexit((void (*)(void))(p->base + dyn[DT_FINI]));
+ if (dyn[0] & (1<<DT_INIT))
+ ((void (*)(void))(p->base + dyn[DT_INIT]))();
+ p->constructed = 1;
+ }
+}
+
+void *__dynlink(int argc, char **argv)