fix breakage in dlsym for looking up RTLD_DEFAULT, etc.
authorRich Felker <dalias@aerifal.cx>
Sat, 20 Oct 2012 01:41:30 +0000 (21:41 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 20 Oct 2012 01:41:30 +0000 (21:41 -0400)
this was broken during the early dynamic-linked TLS commits, which
rearranged some of the code for handling new relocation types.

src/ldso/dynlink.c

index 2ec8fb8..39a2760 100644 (file)
@@ -1080,11 +1080,14 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra)
        uint32_t h = 0, gh = 0;
        Sym *sym;
        if (p == head || p == RTLD_DEFAULT || p == RTLD_NEXT) {
        uint32_t h = 0, gh = 0;
        Sym *sym;
        if (p == head || p == RTLD_DEFAULT || p == RTLD_NEXT) {
-               if (p == RTLD_NEXT) {
+               if (p == RTLD_DEFAULT) {
+                       p = head;
+               } else if (p == RTLD_NEXT) {
                        for (p=head; p && (unsigned char *)ra-p->map>p->map_len; p=p->next);
                        if (!p) p=head;
                        for (p=head; p && (unsigned char *)ra-p->map>p->map_len; p=p->next);
                        if (!p) p=head;
+                       p = p->next;
                }
                }
-               struct symdef def = find_sym(p->next, s, 0);
+               struct symdef def = find_sym(p, s, 0);
                if (!def.sym) goto failed;
                return def.dso->base + def.sym->st_value;
        }
                if (!def.sym) goto failed;
                return def.dso->base + def.sym->st_value;
        }