don't continue looping through ioctl compat_map after finding match
[musl] / src / ldso / dl_iterate_phdr.c
index e55cbf7..86c87ef 100644 (file)
@@ -4,6 +4,8 @@
 
 #define AUX_CNT 38
 
+extern weak hidden const size_t _DYNAMIC[];
+
 static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void *data), void *data)
 {
        unsigned char *p;
@@ -20,6 +22,8 @@ static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size
                phdr = (void *)p;
                if (phdr->p_type == PT_PHDR)
                        base = aux[AT_PHDR] - phdr->p_vaddr;
+               if (phdr->p_type == PT_DYNAMIC && _DYNAMIC)
+                       base = (size_t)_DYNAMIC - phdr->p_vaddr;
                if (phdr->p_type == PT_TLS)
                        tls_phdr = phdr;
        }