the error status is required to be sticky after failure of dlopen or
dlsym until cleared by dlerror. applications and especially libraries
should never rely on this since it is not thread-safe and subject to
race conditions, but glib does anyway.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <dlfcn.h>
#include <ctype.h>
#include <dlfcn.h>
+static int errflag;
+
+#ifdef __PIC__
+
#include "reloc.h"
#if ULONG_MAX == 0xffffffff
#include "reloc.h"
#if ULONG_MAX == 0xffffffff
tail = orig_tail;
tail->next = 0;
p = 0;
tail = orig_tail;
tail->next = 0;
p = 0;
+ } else p = load_library(file);
+
+ if (!p) {
+ errflag = 1;
- p = load_library(file);
- if (!p) goto end;
-
/* First load handling */
if (!p->deps) {
load_deps(p);
/* First load handling */
if (!p->deps) {
load_deps(p);
if (!p) p=head;
p=p->next;
}
if (!p) p=head;
p=p->next;
}
- if (p == head || p == RTLD_DEFAULT)
- return find_sym(head, s, 0);
+ if (p == head || p == RTLD_DEFAULT) {
+ void *res = find_sym(head, s, 0);
+ if (!res) errflag = 1;
+ return res;
+ }
h = hash(s);
sym = lookup(s, h, p->syms, p->hashtab, p->strings);
if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
h = hash(s);
sym = lookup(s, h, p->syms, p->hashtab, p->strings);
if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
return p->deps[i]->base + sym->st_value;
}
if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
return p->deps[i]->base + sym->st_value;
}
+ if (!errflag) return 0;
+ errflag = 0;
return "unknown error";
}
return "unknown error";
}