#include <dlfcn.h>
static int errflag;
+static char errbuf[128];
#ifdef __PIC__
ctx = IS_COPY(type) ? dso->next : dso;
sym_val = (size_t)find_sym(ctx, name, IS_PLT(type));
if (!sym_val && sym->st_info>>4 != STB_WEAK) {
+ snprintf(errbuf, sizeof errbuf,
+ "Error relocating %s: %s: symbol not found",
+ dso->name, name);
if (runtime) longjmp(rtld_fail, 1);
- dprintf(2, "%s: symbol not found\n", name);
+ dprintf(2, "%s\n", errbuf);
_exit(127);
}
sym_size = sym->st_size;
if (p->dynv[i] != DT_NEEDED) continue;
dep = load_library(p->strings + p->dynv[i+1]);
if (!dep) {
- if (runtime) longjmp(rtld_fail, 1);
- dprintf(2, "%s: %m (needed by %s)\n",
+ snprintf(errbuf, sizeof errbuf,
+ "Error loading shared library %s: %m (needed by %s)",
p->strings + p->dynv[i+1], p->name);
+ if (runtime) longjmp(rtld_fail, 1);
+ dprintf(2, "%s\n", errbuf);
_exit(127);
}
if (runtime) {
tail = orig_tail;
tail->next = 0;
p = 0;
+ errflag = 1;
+ goto end;
} else p = load_library(file);
if (!p) {
+ snprintf(errbuf, sizeof errbuf,
+ "Error loading shared library %s: %m", file);
errflag = 1;
goto end;
}
return p->deps[i]->base + sym->st_value;
}
errflag = 1;
+ snprintf(errbuf, sizeof errbuf, "Symbol not found: %s", s);
return 0;
}
{
if (!errflag) return 0;
errflag = 0;
- return "unknown error";
+ return errbuf;
}
int dlclose(void *p)