clean up search_vec usage for vdso
[musl] / src / ldso / dynlink.c
index d7d6800..981288c 100644 (file)
@@ -81,6 +81,7 @@ static int ldso_fail;
 static jmp_buf rtld_fail;
 static pthread_rwlock_t lock;
 static struct debug debug;
 static jmp_buf rtld_fail;
 static pthread_rwlock_t lock;
 static struct debug debug;
+static size_t *auxv;
 
 struct debug *_dl_debug_addr = &debug;
 
 
 struct debug *_dl_debug_addr = &debug;
 
@@ -603,7 +604,7 @@ void _dl_debug_state(void)
 
 void *__dynlink(int argc, char **argv)
 {
 
 void *__dynlink(int argc, char **argv)
 {
-       size_t *auxv, aux[AUX_CNT] = {0};
+       size_t aux[AUX_CNT] = {0};
        size_t i;
        Phdr *phdr;
        Ehdr *ehdr;
        size_t i;
        Phdr *phdr;
        Ehdr *ehdr;
@@ -612,6 +613,7 @@ void *__dynlink(int argc, char **argv)
        struct dso *const lib = builtin_dsos+1;
        struct dso *const vdso = builtin_dsos+2;
        char *env_preload=0;
        struct dso *const lib = builtin_dsos+1;
        struct dso *const vdso = builtin_dsos+2;
        char *env_preload=0;
+       size_t vdso_base;
 
        /* Find aux vector just past environ[] */
        for (i=argc+1; argv[i]; i++)
 
        /* Find aux vector just past environ[] */
        for (i=argc+1; argv[i]; i++)
@@ -700,9 +702,7 @@ void *__dynlink(int argc, char **argv)
        decode_dyn(app);
 
        /* Attach to vdso, if provided by the kernel */
        decode_dyn(app);
 
        /* Attach to vdso, if provided by the kernel */
-       for (i=0; auxv[i]; i+=2) {
-               size_t vdso_base = auxv[i+1];
-               if (auxv[i] != AT_SYSINFO_EHDR) continue;
+       if (search_vec(auxv, &vdso_base, AT_SYSINFO_EHDR)) {
                ehdr = (void *)vdso_base;
                phdr = (void *)(vdso_base + ehdr->e_phoff);
                for (i=ehdr->e_phnum; i; i--, phdr=(void *)((char *)phdr + ehdr->e_phentsize)) {
                ehdr = (void *)vdso_base;
                phdr = (void *)(vdso_base + ehdr->e_phoff);
                for (i=ehdr->e_phnum; i; i--, phdr=(void *)((char *)phdr + ehdr->e_phentsize)) {
@@ -716,7 +716,6 @@ void *__dynlink(int argc, char **argv)
                decode_dyn(vdso);
                vdso->prev = lib;
                lib->next = vdso;
                decode_dyn(vdso);
                vdso->prev = lib;
                lib->next = vdso;
-               break;
        }
 
        /* Initial dso chain consists only of the app. We temporarily
        }
 
        /* Initial dso chain consists only of the app. We temporarily
@@ -838,6 +837,8 @@ void *dlopen(const char *file, int mode)
                p->global = 1;
        }
 
                p->global = 1;
        }
 
+       if (ssp_used) __init_ssp(auxv);
+
        _dl_debug_state();
 
        do_init_fini(tail);
        _dl_debug_state();
 
        do_init_fini(tail);