summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2002-11-14 15:15:55 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2002-11-14 15:15:55 +0000
commit44075a99e43efca7c637069c0588b5d09c6dc4d5 (patch)
treeee6bfd462cec2903b80d0d470e2ded977125c9c8
parentfe8301cb0911366f651960c3fa105c7cb6288cb3 (diff)
Make error messages on symbol lookup failures more useful.
-rw-r--r--libexec/ld.so/alpha/rtld_machine.c11
-rw-r--r--libexec/ld.so/dlfcn.c4
-rw-r--r--libexec/ld.so/i386/rtld_machine.c6
-rw-r--r--libexec/ld.so/loader.c4
-rw-r--r--libexec/ld.so/mips/rtld_machine.c8
-rw-r--r--libexec/ld.so/powerpc/rtld_machine.c9
-rw-r--r--libexec/ld.so/resolve.c18
-rw-r--r--libexec/ld.so/resolve.h4
-rw-r--r--libexec/ld.so/sparc/rtld_machine.c8
-rw-r--r--libexec/ld.so/sparc64/rtld_machine.c8
10 files changed, 41 insertions, 39 deletions
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c
index 1e3bfb123ac..0c10637104d 100644
--- a/libexec/ld.so/alpha/rtld_machine.c
+++ b/libexec/ld.so/alpha/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.16 2002/09/01 23:55:01 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.17 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -113,7 +113,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
case R_TYPE(REFQUAD):
ooff = _dl_find_symbol(symn, _dl_objects, &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT,
- sym->st_size);
+ sym->st_size, object->load_name);
if (this == NULL)
goto resolve_failed;
*r_addr += ooff + this->st_value + relas->r_addend;
@@ -138,7 +138,7 @@ _dl_printf("unaligned RELATIVE: %p type: %d %s 0x%lx -> 0x%lx\n", r_addr,
case R_TYPE(JMP_SLOT):
ooff = _dl_find_symbol(symn, _dl_objects, &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT,
- sym->st_size);
+ sym->st_size, object->load_name);
if (this == NULL)
goto resolve_failed;
*r_addr = ooff + this->st_value + relas->r_addend;
@@ -146,7 +146,7 @@ _dl_printf("unaligned RELATIVE: %p type: %d %s 0x%lx -> 0x%lx\n", r_addr,
case R_TYPE(GLOB_DAT):
ooff = _dl_find_symbol(symn, _dl_objects, &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT,
- sym->st_size);
+ sym->st_size, object->load_name);
if (this == NULL)
goto resolve_failed;
*r_addr = ooff + this->st_value + relas->r_addend;
@@ -199,7 +199,8 @@ _dl_bind(elf_object_t *object, Elf_Word reloff)
addr = (Elf_Addr *)(object->load_offs + rela->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, _dl_objects, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ object->load_name);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index fa8282d5557..07c4df9aaf9 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.21 2002/10/04 03:01:42 drahn Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.22 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -128,7 +128,7 @@ dlsym(void *handle, const char *name)
}
retval = (void *)_dl_find_symbol(name, object, &sym,
- SYM_SEARCH_SELF|SYM_WARNNOTFOUND|SYM_NOTPLT, 0);
+ SYM_SEARCH_SELF|SYM_WARNNOTFOUND|SYM_NOTPLT, 0, object->load_name);
if (sym != NULL)
retval += sym->st_value;
else
diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c
index b207ae8d538..a61a3edf531 100644
--- a/libexec/ld.so/i386/rtld_machine.c
+++ b/libexec/ld.so/i386/rtld_machine.c
@@ -175,7 +175,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
&this, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT))?
SYM_PLT:SYM_NOTPLT),
- sym->st_size);
+ sym->st_size, object->load_name);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -204,7 +204,7 @@ resolve_failed:
soff = _dl_find_symbol(symn, object->next, &srcsym,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT:SYM_NOTPLT),
- size);
+ size, object->load_name);
if (srcsym == NULL)
goto resolve_failed;
@@ -298,7 +298,7 @@ _dl_bind(elf_object_t *object, int index)
addr = (Elf_Word *)(object->load_offs + rel->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, _dl_objects, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, 0);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, 0, object->load_name);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index 53cea0c1270..819fa60ce7e 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.51 2002/10/25 10:39:51 pefo Exp $ */
+/* $OpenBSD: loader.c,v 1.52 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -257,7 +257,7 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
sym = NULL;
ooff = _dl_find_symbol("atexit", _dl_objects, &sym,
- SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0);
+ SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, "");
if (sym == NULL) {
_dl_printf("cannot find atexit, destructors will not be run!\n");
} else {
diff --git a/libexec/ld.so/mips/rtld_machine.c b/libexec/ld.so/mips/rtld_machine.c
index 9c3eb01fe58..b58e689e7fa 100644
--- a/libexec/ld.so/mips/rtld_machine.c
+++ b/libexec/ld.so/mips/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.8 2002/10/25 10:39:52 pefo Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.9 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -77,7 +77,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
ELF32_ST_TYPE (sym->st_info) == STT_NOTYPE)) {
ooff = _dl_find_symbol(symn, _dl_objects, &this,
SYM_SEARCH_ALL | SYM_NOWARNNOTFOUND | SYM_PLT,
- sym->st_size);
+ sym->st_size, object->load_name);
if (!this && ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
_dl_printf("%s: can't resolve reference '%s'\n",
_dl_progname, symn);
@@ -172,7 +172,7 @@ DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value));
ooff = _dl_find_symbol(strt + symp->st_name,
_dl_objects, &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- symp->st_size);
+ symp->st_size, object->load_name);
if (this)
*gotp = this->st_value + ooff;
} else
@@ -183,7 +183,7 @@ DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value));
ooff = _dl_find_symbol(strt + symp->st_name,
_dl_objects, &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- symp->st_size);
+ symp->st_size, object->load_name);
if (this)
*gotp = this->st_value + ooff;
} else if (ELF32_ST_TYPE(symp->st_info) == STT_FUNC) {
diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c
index 389e7fd353d..1e6bcaa6334 100644
--- a/libexec/ld.so/powerpc/rtld_machine.c
+++ b/libexec/ld.so/powerpc/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.16 2002/11/05 16:53:19 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.17 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -202,7 +202,7 @@ _dl_printf("object relocation size %x, numrela %x\n",
ooff = _dl_find_symbol(symn, _dl_objects, &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|
((type == RELOC_JMP_SLOT) ? SYM_PLT:SYM_NOTPLT),
- sym->st_size);
+ sym->st_size, object->load_name);
if (!this && ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
_dl_printf("%s: %s :can't resolve reference '%s'\n",
@@ -393,7 +393,7 @@ _dl_printf(" symn [%s] val 0x%x\n", symn, val);
SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|
((type == RELOC_JMP_SLOT) ?
SYM_PLT : SYM_NOTPLT),
- sym->st_size);
+ sym->st_size, object->load_name);
}
}
if (cpysrc == NULL) {
@@ -503,7 +503,8 @@ _dl_bind(elf_object_t *object, int reloff)
r_addr = (Elf_Addr *)(object->load_offs + relas->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, _dl_objects, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, SYM_NOTPLT);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, SYM_NOTPLT,
+ object->load_name);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */
diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c
index f26cf307181..fa208fa809a 100644
--- a/libexec/ld.so/resolve.c
+++ b/libexec/ld.so/resolve.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.c,v 1.13 2002/08/23 22:57:03 drahn Exp $ */
+/* $OpenBSD: resolve.c,v 1.14 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -175,10 +175,10 @@ _dl_lookup_object(const char *name)
Elf_Addr
_dl_find_symbol(const char *name, elf_object_t *startlook,
- const Elf_Sym **ref, int flags, int req_size)
+ const Elf_Sym **ref, int flags, int req_size, const char *module_name)
{
const Elf_Sym *weak_sym = 0;
- const char *weak_symn = ""; /* remove warning */
+ const char *weak_symn = NULL; /* remove warning */
Elf_Addr weak_offs = 0;
unsigned long h = 0;
const char *p = name;
@@ -253,18 +253,18 @@ _dl_find_symbol(const char *name, elf_object_t *startlook,
}
}
if (flags & SYM_WARNNOTFOUND) {
- if (!weak_sym && *ref &&
- ELF_ST_BIND((*ref)->st_info) != STB_WEAK) {
- _dl_printf("%s: undefined symbol '%s'\n",
- _dl_progname, name);
+ if (!weak_sym && ((*ref == NULL) ||
+ ELF_ST_BIND((*ref)->st_info) != STB_WEAK)) {
+ _dl_printf("%s:%s: undefined symbol '%s'\n",
+ _dl_progname, module_name, name);
}
}
*ref = weak_sym;
if (weak_sym && req_size != weak_sym->st_size &&
req_size != 0 && (ELF_ST_TYPE(weak_sym->st_info) != STT_FUNC)) {
- _dl_printf("%s: %s : WARNING: "
+ _dl_printf("%s:%s: %s : WARNING: "
"symbol(%s) size mismatch ",
- _dl_progname, object->load_name,
+ _dl_progname, module_name, object->load_name,
weak_symn);
_dl_printf("relink your program\n");
}
diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h
index 3af79fab45e..8e0060698d3 100644
--- a/libexec/ld.so/resolve.h
+++ b/libexec/ld.so/resolve.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.h,v 1.17 2002/08/23 22:57:03 drahn Exp $ */
+/* $OpenBSD: resolve.h,v 1.18 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -134,7 +134,7 @@ extern int _dl_md_reloc(elf_object_t *object, int rel, int relsz);
extern void _dl_md_reloc_got(elf_object_t *object, int lazy);
Elf_Addr _dl_find_symbol(const char *name, elf_object_t *startlook,
- const Elf_Sym **ref, int flags, int sym_size);
+ const Elf_Sym **ref, int flags, int sym_size, const char *module_name);
/*
* defines for _dl_find_symbol() flag field, three bits of meaning
* myself - clear: search all objects, set: search only this object
diff --git a/libexec/ld.so/sparc/rtld_machine.c b/libexec/ld.so/sparc/rtld_machine.c
index 6178d17a90f..d92ede5ad01 100644
--- a/libexec/ld.so/sparc/rtld_machine.c
+++ b/libexec/ld.so/sparc/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.8 2002/09/01 23:55:01 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.9 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -258,7 +258,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JMP_SLOT)) ?
SYM_PLT : SYM_NOTPLT),
- sym->st_size);
+ sym->st_size, object->load_name);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -283,7 +283,7 @@ resolve_failed:
soff = _dl_find_symbol(symn, object->next, &srcsym,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JMP_SLOT)) ? SYM_PLT : SYM_NOTPLT),
- size);
+ size, object->load_name);
if (srcsym == NULL)
goto resolve_failed;
@@ -342,7 +342,7 @@ _dl_bind(elf_object_t *object, Elf_Word reloff)
addr = (Elf_Addr *)(object->load_offs + rela->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, _dl_objects, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, 0);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, 0, object->load_name);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */
diff --git a/libexec/ld.so/sparc64/rtld_machine.c b/libexec/ld.so/sparc64/rtld_machine.c
index 9a725afa82f..d44c20888a2 100644
--- a/libexec/ld.so/sparc64/rtld_machine.c
+++ b/libexec/ld.so/sparc64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.21 2002/09/01 23:55:01 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.22 2002/11/14 15:15:54 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -280,7 +280,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
&this, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JMP_SLOT))?
SYM_PLT:SYM_NOTPLT),
- sym->st_size);
+ sym->st_size, object->load_name);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -308,7 +308,7 @@ resolve_failed:
soff = _dl_find_symbol(symn, object->next, &srcsym,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT,
- size);
+ size, object->load_name);
if (srcsym == NULL)
goto resolve_failed;
@@ -635,7 +635,7 @@ _dl_bind(elf_object_t *object, int index)
addr = (Elf_Word *)(object->load_offs + rela->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, _dl_objects, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, 0);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, 0, object->load_name);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */