It seems very wrong that this find_timekeep() function is called 3 times, and EACH TIME it walks the same two arrays, AND I expect bad things to happen if a program messes with it's environment early on, meaning this stops pointing to a place the right place on the stack:
> + stackp = (Elf_Addr *)environ; Whatever find_timekeep() is, it should be done only once, and I don't think you have found the right place to perform the initialization and store it into a global variable which all future consumers can hinge off. > int > dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), > void *data) > { > + find_timekeep(); > if (_dl_cb != NULL && _dl_cb->dl_iterate_phdr != NULL) > return _dl_cb->dl_iterate_phdr(callback, data); ... > void _libc_preinit(int, char **, char **, dl_cb_cb *) __dso_hidden; > void > _libc_preinit(int argc, char **argv, char **envp, dl_cb_cb *cb) > @@ -126,6 +129,7 @@ _libc_preinit(int argc, char **argv, char **envp, > dl_cb_cb *cb) > if (cb == NULL) > setup_static_tib(phdr, phnum); > #endif /* !PIC */ > + find_timekeep(); > } .... > +int > +WRAP(clock_gettime)(clockid_t clock_id, struct timespec *tp) > +{ > + struct timekeep *timekeep; > + > + if (elf_aux_timekeep == NULL && find_timekeep()) > + return clock_gettime(clock_id, tp); > + timekeep = elf_aux_timekeep;