rewrite bump allocator to fix corner cases, decouple from expand_heap
[musl] / ldso / dynlink.c
index acd2b20..f692691 100644 (file)
@@ -23,7 +23,6 @@
 #include "pthread_impl.h"
 #include "libc.h"
 #include "dynlink.h"
-#include "malloc_impl.h"
 
 static void error(const char *, ...);
 
@@ -185,8 +184,14 @@ static void *laddr_pg(const struct dso *p, size_t v)
        }
        return (void *)(v - p->loadmap->segs[j].p_vaddr + p->loadmap->segs[j].addr);
 }
-#define fpaddr(p, v) ((void (*)())&(struct funcdesc){ \
-       laddr(p, v), (p)->got })
+static void (*fdbarrier(void *p))()
+{
+       void (*fd)();
+       __asm__("" : "=r"(fd) : "0"(p));
+       return fd;
+}
+#define fpaddr(p, v) fdbarrier((&(struct funcdesc){ \
+       laddr(p, v), (p)->got }))
 #else
 #define laddr(p, v) (void *)((p)->base + (v))
 #define laddr_pg(p, v) laddr(p, v)
@@ -409,8 +414,6 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
                }
 
                switch(type) {
-               case REL_NONE:
-                       break;
                case REL_OFFSET:
                        addend -= (size_t)reloc_addr;
                case REL_SYMBOLIC:
@@ -1664,6 +1667,7 @@ void __dls2b(size_t *sp, size_t *auxv)
        /* Setup early thread pointer in builtin_tls for ldso/libc itself to
         * use during dynamic linking. If possible it will also serve as the
         * thread pointer at runtime. */
+       search_vec(auxv, &__hwcap, AT_HWCAP);
        libc.auxv = auxv;
        libc.tls_size = sizeof builtin_tls;
        libc.tls_align = tls_align;
@@ -1698,7 +1702,6 @@ void __dls3(size_t *sp, size_t *auxv)
         * global data that may be needed before we can make syscalls. */
        __environ = envp;
        decode_vec(auxv, aux, AUX_CNT);
-       __hwcap = aux[AT_HWCAP];
        search_vec(auxv, &__sysinfo, AT_SYSINFO);
        __pthread_self()->sysinfo = __sysinfo;
        libc.page_size = aux[AT_PAGESZ];