summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2005-09-21 23:12:12 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2005-09-21 23:12:12 +0000
commit167e3760d86ba62a9da0d07fe138e4121997246b (patch)
treec594795ac03e0da8b00fba4bbe336ee85cb61b89 /libexec
parent63e90dafb93b6a3e64ad9102d8e9c4045a03ea3a (diff)
Simplify the internal symbol finding API, with some cleanup, prep for
next step. ok kurt@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ld.so/alpha/rtld_machine.c18
-rw-r--r--libexec/ld.so/amd64/rtld_machine.c15
-rw-r--r--libexec/ld.so/arm/rtld_machine.c18
-rw-r--r--libexec/ld.so/hppa/rtld_machine.c28
-rw-r--r--libexec/ld.so/i386/rtld_machine.c15
-rw-r--r--libexec/ld.so/loader.c6
-rw-r--r--libexec/ld.so/mips64/rtld_machine.c40
-rw-r--r--libexec/ld.so/powerpc/rtld_machine.c33
-rw-r--r--libexec/ld.so/resolve.c40
-rw-r--r--libexec/ld.so/resolve.h10
-rw-r--r--libexec/ld.so/sparc/rtld_machine.c16
-rw-r--r--libexec/ld.so/sparc64/rtld_machine.c16
12 files changed, 131 insertions, 124 deletions
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c
index d64b1fd89cb..53067ec4f08 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.32 2005/09/16 23:19:41 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.33 2005/09/21 23:12:09 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -98,7 +98,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
ooff = _dl_find_symbol_bysym(object,
ELF64_R_SYM(relas->r_info), &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT,
- sym->st_size, NULL);
+ sym, NULL);
if (this == NULL)
goto resolve_failed;
*r_addr += ooff + this->st_value + relas->r_addend;
@@ -123,7 +123,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, &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT,
- sym->st_size, object, NULL);
+ sym, object, NULL);
if (this == NULL)
goto resolve_failed;
*r_addr = ooff + this->st_value + relas->r_addend;
@@ -132,7 +132,7 @@ _dl_printf("unaligned RELATIVE: %p type: %d %s 0x%lx -> 0x%lx\n", r_addr,
ooff = _dl_find_symbol_bysym(object,
ELF64_R_SYM(relas->r_info), &this,
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT,
- sym->st_size, NULL);
+ sym, NULL);
if (this == NULL)
goto resolve_failed;
*r_addr = ooff + this->st_value + relas->r_addend;
@@ -186,7 +186,7 @@ _dl_bind(elf_object_t *object, int reloff)
addr = (Elf_Addr *)(object->load_offs + rela->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym,
object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
@@ -231,13 +231,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
@@ -245,13 +245,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->plt_size = 0;
this = NULL;
ooff = _dl_find_symbol("__plt_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
plt_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__plt_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->plt_size = ooff + this->st_value - plt_addr;
diff --git a/libexec/ld.so/amd64/rtld_machine.c b/libexec/ld.so/amd64/rtld_machine.c
index 2dd82c91183..9bd9826e683 100644
--- a/libexec/ld.so/amd64/rtld_machine.c
+++ b/libexec/ld.so/amd64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.8 2005/09/16 23:19:41 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.9 2005/09/21 23:12:09 drahn Exp $ */
/*
* Copyright (c) 2002,2004 Dale Rahn
@@ -238,7 +238,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT))?
SYM_PLT:SYM_NOTPLT),
- sym->st_size, NULL);
+ sym, NULL);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -261,18 +261,17 @@ resolve_failed:
void *dstaddr = where;
const void *srcaddr;
const Elf_Sym *dstsym = sym, *srcsym = NULL;
- size_t size = dstsym->st_size;
Elf_Addr soff;
soff = _dl_find_symbol(symn, &srcsym,
SYM_SEARCH_OTHER|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT:SYM_NOTPLT),
- size, object, NULL);
+ dstsym, object, NULL);
if (srcsym == NULL)
goto resolve_failed;
srcaddr = (void *)(soff + srcsym->st_value);
- _dl_bcopy(srcaddr, dstaddr, size);
+ _dl_bcopy(srcaddr, dstaddr, dstsym->st_size);
continue;
}
@@ -354,7 +353,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, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym,
object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
@@ -406,13 +405,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
diff --git a/libexec/ld.so/arm/rtld_machine.c b/libexec/ld.so/arm/rtld_machine.c
index 15d91736abf..b02306f7e2f 100644
--- a/libexec/ld.so/arm/rtld_machine.c
+++ b/libexec/ld.so/arm/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.7 2005/09/16 23:19:42 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.8 2005/09/21 23:12:10 drahn Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -239,7 +239,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT)) ?
SYM_PLT : SYM_NOTPLT),
- sym->st_size, NULL);
+ sym, NULL);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -265,17 +265,16 @@ resolve_failed:
void *dstaddr = where;
const void *srcaddr;
const Elf_Sym *dstsym = sym, *srcsym = NULL;
- size_t size = dstsym->st_size;
Elf_Addr soff;
soff = _dl_find_symbol(symn, &srcsym,
SYM_SEARCH_OTHER|SYM_WARNNOTFOUND|SYM_NOTPLT,
- size, object, NULL);
+ dstsym, object, NULL);
if (srcsym == NULL)
goto resolve_failed;
srcaddr = (void *)(soff + srcsym->st_value);
- _dl_bcopy(srcaddr, dstaddr, size);
+ _dl_bcopy(srcaddr, dstaddr, dstsym->st_size);
continue;
}
@@ -347,15 +346,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
@@ -409,8 +406,9 @@ _dl_bind(elf_object_t *object, int relidx)
sym += ELF_R_SYM(rel->r_info);
symn = object->dyn.strtab + sym->st_name;
+ this = NULL;
ooff = _dl_find_symbol(symn, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym,
object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
diff --git a/libexec/ld.so/hppa/rtld_machine.c b/libexec/ld.so/hppa/rtld_machine.c
index a7005d41e05..da5602f748a 100644
--- a/libexec/ld.so/hppa/rtld_machine.c
+++ b/libexec/ld.so/hppa/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.8 2005/09/16 23:19:42 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.9 2005/09/21 23:12:10 drahn Exp $ */
/*
* Copyright (c) 2004 Michael Shalayeff
@@ -152,18 +152,19 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
if (type == RELOC_NONE)
continue;
- this = sym = object->dyn.symtab + ELF_R_SYM(rela->r_info);
+ sym = object->dyn.symtab + ELF_R_SYM(rela->r_info);
sobj = object;
symn = object->dyn.strtab + sym->st_name;
pt = (Elf_Addr *)(rela->r_offset + loff);
ooff = 0;
+ this = NULL;
if (ELF_R_SYM(rela->r_info) && sym->st_name) {
ooff = _dl_find_symbol_bysym(object,
ELF_R_SYM(rela->r_info), &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|
((type == RELOC_DIR32) ? SYM_NOTPLT : SYM_PLT),
- sym->st_size, &sobj);
+ sym, &sobj);
if (!this) {
_dl_printf("%s: %s: can't resolve reference '%s'\n",
_dl_progname, object->load_name, symn);
@@ -234,21 +235,23 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
break;
case RELOC_COPY:
+ {
+ const Elf32_Sym *cpysrc = NULL;
size = sym->st_size;
- ooff = _dl_find_symbol(symn, &sym,
+ ooff = _dl_find_symbol(symn, &cpysrc,
SYM_SEARCH_OTHER|SYM_WARNNOTFOUND|SYM_NOTPLT,
- size, object, NULL);
- if (sym) {
- _dl_bcopy((void *)(ooff + sym->st_value),
+ sym, object, NULL);
+ if (cpysrc) {
+ _dl_bcopy((void *)(ooff + cpysrc->st_value),
pt, sym->st_size);
DL_DEB(("[%x]COPY: %s[%x]:%s -> %p[%x] in %s\n",
- i, symn, ooff + sym->st_value,
+ i, symn, ooff + cpysrc->st_value,
object->load_name, pt, sym->st_size,
sobj->load_name));
} else
DL_DEB(("[%x]COPY: no sym\n", i));
break;
-
+ }
default:
DL_DEB(("[%x]UNKNOWN(%d): type=%d off=0x%lx "
"addend=0x%lx rel=0x%x\n", i, type,
@@ -278,13 +281,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL );
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL );
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
@@ -344,8 +347,7 @@ _dl_bind(elf_object_t *object, int reloff)
addr = (Elf_Addr *)(object->load_offs + rela->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
- object, &sobj);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym, object, &sobj);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */
diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c
index 6c891593490..d6b9c188868 100644
--- a/libexec/ld.so/i386/rtld_machine.c
+++ b/libexec/ld.so/i386/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.17 2005/09/16 23:19:42 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.18 2005/09/21 23:12:10 drahn Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -231,7 +231,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT))?
SYM_PLT:SYM_NOTPLT),
- sym->st_size, NULL);
+ sym, NULL);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -260,7 +260,7 @@ resolve_failed:
soff = _dl_find_symbol(symn, &srcsym,
SYM_SEARCH_OTHER|SYM_WARNNOTFOUND|
((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT:SYM_NOTPLT),
- size, object, NULL);
+ sym, object, NULL);
if (srcsym == NULL)
goto resolve_failed;
@@ -357,8 +357,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, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
- object, NULL);
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym, object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
*((int *)0) = 0; /* XXX */
@@ -408,15 +407,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index ef92ae03fb6..5fe58a3f1e3 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.88 2005/09/19 02:31:04 drahn Exp $ */
+/* $OpenBSD: loader.c,v 1.89 2005/09/21 23:12:09 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -507,7 +507,7 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
sym = NULL;
ooff = _dl_find_symbol("atexit", &sym,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- 0, dyn_obj, &sobj);
+ NULL, dyn_obj, &sobj);
if (sym == NULL)
_dl_printf("cannot find atexit, destructors will not be run!\n");
else
@@ -841,7 +841,7 @@ _dl_fixup_user_env(void)
sym = NULL;
ooff = _dl_find_symbol("environ", &sym,
- SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, &dummy_obj, NULL);
+ SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, &dummy_obj, NULL);
if (sym != NULL)
*((char ***)(sym->st_value + ooff)) = _dl_so_envp;
}
diff --git a/libexec/ld.so/mips64/rtld_machine.c b/libexec/ld.so/mips64/rtld_machine.c
index fde75a0bb4f..30acba90d3d 100644
--- a/libexec/ld.so/mips64/rtld_machine.c
+++ b/libexec/ld.so/mips64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.6 2005/09/16 23:19:42 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.7 2005/09/21 23:12:10 drahn Exp $ */
/*
* Copyright (c) 1998-2004 Opsycon AB, Sweden.
@@ -75,14 +75,12 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
got_start = 0;
got_end = 0;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
got_start = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
got_end = ooff + this->st_value;
@@ -98,22 +96,28 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
ooff = 0;
sym = object->dyn.symtab;
sym += ELF64_R_SYM(relocs->r_info);
- this = sym;
symn = object->dyn.strtab + sym->st_name;
type = ELF64_R_TYPE(relocs->r_info);
+ this = NULL;
if (ELF64_R_SYM(relocs->r_info) &&
!(ELF64_ST_BIND(sym->st_info) == STB_LOCAL &&
ELF64_ST_TYPE (sym->st_info) == STT_NOTYPE)) {
ooff = _dl_find_symbol(symn, &this,
SYM_SEARCH_ALL | SYM_NOWARNNOTFOUND | SYM_PLT,
- sym->st_size, object, NULL);
- if (!this && ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
- _dl_printf("%s: can't resolve reference '%s'\n",
- _dl_progname, symn);
- fails++;
- }
+ sym, object, NULL);
+
+ if (this == NULL) {
+ if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
+ _dl_printf("%s: %s :can't resolve "
+ "reference '%s'\n",
+ _dl_progname, object->load_name,
+ symn);
+ fails++;
+ }
+ continue;
+ }
}
switch (ELF64_R_TYPE(relocs->r_info)) {
@@ -215,15 +219,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->plt_size = 0;
object->got_size = 0;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_start = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
- object, NULL);
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL, object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_start;
@@ -239,7 +241,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
ooff = _dl_find_symbol(strt + symp->st_name,
&this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- symp->st_size, object, NULL);
+ symp, object, NULL);
if (this)
*gotp = this->st_value + ooff;
} else
@@ -249,7 +251,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
this = 0;
ooff = _dl_find_symbol(strt + symp->st_name, &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- symp->st_size, object, NULL);
+ symp, object, NULL);
if (this)
*gotp = this->st_value + ooff;
} else if (ELF64_ST_TYPE(symp->st_info) == STT_FUNC &&
@@ -259,7 +261,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
this = 0;
ooff = _dl_find_symbol(strt + symp->st_name, &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- symp->st_size, object, NULL);
+ symp, object, NULL);
if (this)
*gotp = this->st_value + ooff;
else
diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c
index bb8d7eab9c1..edb3dd1aa56 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.36 2005/09/16 23:19:42 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.37 2005/09/21 23:12:11 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -185,11 +185,10 @@ _dl_printf("object relocation size %x, numrela %x\n",
sym = object->dyn.symtab;
sym += ELF32_R_SYM(relas->r_info);
- this = sym;
symn = object->dyn.strtab + sym->st_name;
ooff = 0;
-
+ this = NULL;
if (ELF32_R_SYM(relas->r_info) &&
!(ELF32_ST_BIND(sym->st_info) == STB_LOCAL &&
ELF32_ST_TYPE (sym->st_info) == STT_NOTYPE)) {
@@ -197,12 +196,18 @@ _dl_printf("object relocation size %x, numrela %x\n",
ELF32_R_SYM(relas->r_info), &this,
SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|
((type == RELOC_JMP_SLOT) ? SYM_PLT:SYM_NOTPLT),
- sym->st_size, NULL);
+ sym, NULL);
+
+ if (this == NULL) {
+ if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
+ _dl_printf("%s: %s :can't resolve "
+ "reference '%s'\n",
+ _dl_progname, object->load_name,
+ symn);
- if (!this && ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
- _dl_printf("%s: %s :can't resolve reference '%s'\n",
- _dl_progname, object->load_name, symn);
- fails++;
+ fails++;
+ }
+ continue;
}
}
@@ -380,7 +385,7 @@ _dl_printf(" symn [%s] val 0x%x\n", symn, val);
src_loff = 0;
src_loff = _dl_find_symbol(symn, &cpysrc,
SYM_SEARCH_OTHER|SYM_NOWARNNOTFOUND| SYM_NOTPLT,
- sym->st_size, object, NULL);
+ sym, object, NULL);
if (cpysrc == NULL) {
_dl_printf("symbol not found [%s] \n", symn);
} else {
@@ -448,14 +453,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, NULL,
object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, NULL,
object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
@@ -464,14 +469,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->plt_size = 0;
this = NULL;
ooff = _dl_find_symbol("__plt_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, NULL,
object, NULL);
if (this != NULL)
plt_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__plt_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT|SYM_DLSYM, NULL,
object, NULL);
if (this != NULL)
object->plt_size = ooff + this->st_value - plt_addr;
@@ -556,7 +561,7 @@ _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, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym,
object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c
index d79362cf0de..1a39efab9b0 100644
--- a/libexec/ld.so/resolve.c
+++ b/libexec/ld.so/resolve.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.c,v 1.31 2005/09/19 21:08:43 kurt Exp $ */
+/* $OpenBSD: resolve.c,v 1.32 2005/09/21 23:12:09 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -211,7 +211,7 @@ int _dl_symcachestat_lookups;
Elf_Addr
_dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx,
- const Elf_Sym **ref, int flags, int req_size, const elf_object_t **pobj)
+ const Elf_Sym **this, int flags, const Elf_Sym *ref_sym, const elf_object_t **pobj)
{
Elf_Addr ret;
const Elf_Sym *sym;
@@ -227,7 +227,7 @@ _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx,
_dl_symcachestat_hits++;
sobj = _dl_symcache[symidx].obj;
- *ref = _dl_symcache[symidx].sym;
+ *this = _dl_symcache[symidx].sym;
if (pobj)
*pobj = sobj;
return sobj->load_offs;
@@ -237,14 +237,14 @@ _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx,
sym += symidx;
symn = req_obj->dyn.strtab + sym->st_name;
- ret = _dl_find_symbol(symn, ref, flags, req_size, req_obj, &sobj);
+ ret = _dl_find_symbol(symn, this, flags, ref_sym, req_obj, &sobj);
if (pobj)
*pobj = sobj;
if ((_dl_symcache != NULL) &&
(symidx < req_obj->nchains)) {
- _dl_symcache[symidx].sym = *ref;
+ _dl_symcache[symidx].sym = *this;
_dl_symcache[symidx].obj = sobj;
_dl_symcache[symidx].flags = flags;
}
@@ -253,8 +253,9 @@ _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx,
}
Elf_Addr
-_dl_find_symbol(const char *name, const Elf_Sym **ref,
- int flags, int req_size, elf_object_t *req_obj, const elf_object_t **pobj)
+_dl_find_symbol(const char *name, const Elf_Sym **this,
+ int flags, const Elf_Sym *ref_sym, elf_object_t *req_obj,
+ const elf_object_t **pobj)
{
const Elf_Sym *weak_sym = NULL;
unsigned long h = 0;
@@ -273,7 +274,7 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref,
}
if (req_obj->dyn.symbolic)
- if (_dl_find_symbol_obj(req_obj, name, h, flags, ref, &weak_sym,
+ if (_dl_find_symbol_obj(req_obj, name, h, flags, this, &weak_sym,
&weak_object)) {
object = req_obj;
found = 1;
@@ -281,20 +282,20 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref,
}
if (flags & SYM_SEARCH_OBJ) {
- if (_dl_find_symbol_obj(req_obj, name, h, flags, ref,
+ if (_dl_find_symbol_obj(req_obj, name, h, flags, this,
&weak_sym, &weak_object)) {
object = req_obj;
found = 1;
}
} else if (flags & SYM_DLSYM) {
- if (_dl_find_symbol_obj(req_obj, name, h, flags, ref,
+ if (_dl_find_symbol_obj(req_obj, name, h, flags, this,
&weak_sym, &weak_object)) {
object = req_obj;
found = 1;
}
if (weak_object != NULL && found == 0) {
object=weak_object;
- *ref = weak_sym;
+ *this = weak_sym;
found = 1;
}
/* search dlopened obj and all children */
@@ -303,7 +304,7 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref,
TAILQ_FOREACH(n, &req_obj->load_object->dload_list,
next_sib) {
if (_dl_find_symbol_obj(n->data, name, h,
- flags, ref,
+ flags, this,
&weak_sym, &weak_object)) {
object = n->data;
found = 1;
@@ -339,7 +340,7 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref,
(m->data == req_obj))
continue;
if (_dl_find_symbol_obj(m->data, name, h, flags,
- ref, &weak_sym, &weak_object)) {
+ this, &weak_sym, &weak_object)) {
object = m->data;
found = 1;
goto found;
@@ -351,7 +352,7 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref,
found:
if (weak_object != NULL && found == 0) {
object=weak_object;
- *ref = weak_sym;
+ *this = weak_sym;
found = 1;
}
@@ -363,8 +364,9 @@ found:
return (0);
}
- if (req_size != (*ref)->st_size && req_size != 0 &&
- (ELF_ST_TYPE((*ref)->st_info) != STT_FUNC)) {
+ if (ref_sym != NULL && ref_sym->st_size != 0 &&
+ (ref_sym->st_size != (*this)->st_size) &&
+ (ELF_ST_TYPE((*this)->st_info) != STT_FUNC) ) {
_dl_printf("%s:%s: %s : WARNING: "
"symbol(%s) size mismatch, relink your program\n",
_dl_progname, req_obj->load_name,
@@ -379,7 +381,7 @@ found:
int
_dl_find_symbol_obj(elf_object_t *object, const char *name, unsigned long hash,
- int flags, const Elf_Sym **ref, const Elf_Sym **weak_sym,
+ int flags, const Elf_Sym **this, const Elf_Sym **weak_sym,
elf_object_t **weak_object)
{
const Elf_Sym *symt = object->dyn.symtab;
@@ -400,7 +402,7 @@ _dl_find_symbol_obj(elf_object_t *object, const char *name, unsigned long hash,
continue;
symn = strt + sym->st_name;
- if (sym != *ref && _dl_strcmp(symn, name))
+ if (sym != *this && _dl_strcmp(symn, name))
continue;
/* allow this symbol if we are referring to a function
@@ -417,7 +419,7 @@ _dl_find_symbol_obj(elf_object_t *object, const char *name, unsigned long hash,
}
if (ELF_ST_BIND(sym->st_info) == STB_GLOBAL) {
- *ref = sym;
+ *this = sym;
return 1;
} else if (ELF_ST_BIND(sym->st_info) == STB_WEAK) {
if (!*weak_sym) {
diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h
index 7ca2bb65b14..2930fd9fbb9 100644
--- a/libexec/ld.so/resolve.h
+++ b/libexec/ld.so/resolve.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.h,v 1.38 2005/09/17 03:02:37 drahn Exp $ */
+/* $OpenBSD: resolve.h,v 1.39 2005/09/21 23:12:09 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -154,10 +154,12 @@ elf_object_t *_dl_tryload_shlib(const char *libname, int type, int flags);
int _dl_md_reloc(elf_object_t *object, int rel, int relsz);
void _dl_md_reloc_got(elf_object_t *object, int lazy);
-Elf_Addr _dl_find_symbol(const char *name, const Elf_Sym **ref,
- int flags, int sym_size, elf_object_t *object, const elf_object_t **pobj);
+Elf_Addr _dl_find_symbol(const char *name, const Elf_Sym **this,
+ int flags, const Elf_Sym *ref_sym, elf_object_t *object,
+ const elf_object_t **pobj);
Elf_Addr _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx,
- const Elf_Sym **ref, int flags, int req_size, const elf_object_t **pobj);
+ const Elf_Sym **ref, int flags, const Elf_Sym *ref_sym,
+ const elf_object_t **pobj);
/*
* 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 713fcc86289..9e41e4aa401 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.24 2005/09/16 23:19:43 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.25 2005/09/21 23:12:11 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -245,7 +245,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, NULL);
+ sym, NULL);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -270,7 +270,7 @@ resolve_failed:
soff = _dl_find_symbol(symn, &srcsym,
SYM_SEARCH_OTHER|SYM_WARNNOTFOUND|
((type == R_TYPE(JMP_SLOT)) ? SYM_PLT : SYM_NOTPLT),
- size, object, NULL);
+ dstsym, object, NULL);
if (srcsym == NULL)
goto resolve_failed;
@@ -330,7 +330,7 @@ _dl_bind(elf_object_t *object, int reloff)
addr = (Elf_Addr *)(object->load_offs + rela->r_offset);
this = NULL;
ooff = _dl_find_symbol(symn, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym,
object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
@@ -403,14 +403,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
@@ -419,14 +419,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->plt_size = 0;
this = NULL;
ooff = _dl_find_symbol("__plt_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
plt_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__plt_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
object->plt_size = ooff + this->st_value - plt_addr;
diff --git a/libexec/ld.so/sparc64/rtld_machine.c b/libexec/ld.so/sparc64/rtld_machine.c
index 92c92db08ac..78b6db69b64 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.35 2005/09/16 23:19:43 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.36 2005/09/21 23:12:11 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -266,7 +266,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, NULL);
+ sym, NULL);
if (this == NULL) {
resolve_failed:
_dl_printf("%s: %s: can't resolve "
@@ -294,7 +294,7 @@ resolve_failed:
soff = _dl_find_symbol(symn, &srcsym,
SYM_SEARCH_OTHER|SYM_WARNNOTFOUND|SYM_NOTPLT,
- size, object, NULL);
+ dstsym, object, NULL);
if (srcsym == NULL)
goto resolve_failed;
@@ -622,7 +622,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, &this,
- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size,
+ SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym,
object, NULL);
if (this == NULL) {
_dl_printf("lazy binding failed!\n");
@@ -696,14 +696,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
object->got_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__got_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
@@ -712,14 +712,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
object->plt_size = 0;
this = NULL;
ooff = _dl_find_symbol("__plt_start", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
plt_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__plt_end", &this,
- SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, 0,
+ SYM_SEARCH_OBJ|SYM_NOWARNNOTFOUND|SYM_PLT, NULL,
object, NULL);
if (this != NULL)
object->plt_size = ooff + this->st_value - plt_addr;