the asm wrapper is needed to get the return address without
compiler-specific extensions.
--- /dev/null
+#include <dlfcn.h>
+
+void *__dlsym(void *, const char *, void *);
+
+void *dlsym(void *p, const char *s)
+{
+ return __dlsym(p, s, 0);
+}
-static void *do_dlsym(struct dso *p, const char *s)
+static void *do_dlsym(struct dso *p, const char *s, void *ra)
{
size_t i;
uint32_t h;
Sym *sym;
{
size_t i;
uint32_t h;
Sym *sym;
+ if (p == RTLD_NEXT) {
+ for (p=head; p && (unsigned char *)ra-p->map>p->map_len; p=p->next);
+ if (!p) p=head;
+ p=p->next;
+ }
if (p == head || p == RTLD_DEFAULT)
return find_sym(head, s, 0);
h = hash(s);
if (p == head || p == RTLD_DEFAULT)
return find_sym(head, s, 0);
h = hash(s);
-void *dlsym(void *p, const char *s)
+void *__dlsym(void *p, const char *s, void *ra)
{
void *res;
pthread_rwlock_rdlock(&lock);
{
void *res;
pthread_rwlock_rdlock(&lock);
+ res = do_dlsym(p, s, ra);
pthread_rwlock_unlock(&lock);
return res;
}
pthread_rwlock_unlock(&lock);
return res;
}
--- /dev/null
+.text
+.global dlsym
+.type dlsym,@function
+dlsym:
+ push (%esp)
+ push 12(%esp)
+ push 12(%esp)
+ call __dlsym
+ add $12,%esp
+ ret
--- /dev/null
+.text
+.global dlsym
+.type dlsym,@function
+dlsym:
+ mov (%rsp),%edx
+ jmp __dlsym