diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-05-25 18:07:22 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-05-25 18:07:22 +0000 |
commit | 09c2c1a651b8caebf963956ee871e5ea48bcb12b (patch) | |
tree | 625eee2ffbfe0ed2b4c096d9ac2544a5f2ab1dcb | |
parent | 4f40e8347f536a8fa0e2caf3e7014349d1d34217 (diff) |
return object* the symbol is in for _dl_find_symbol*; drahn@ ok
-rw-r--r-- | libexec/ld.so/alpha/rtld_machine.c | 18 | ||||
-rw-r--r-- | libexec/ld.so/amd64/rtld_machine.c | 12 | ||||
-rw-r--r-- | libexec/ld.so/arm/rtld_machine.c | 12 | ||||
-rw-r--r-- | libexec/ld.so/dlfcn.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/i386/rtld_machine.c | 12 | ||||
-rw-r--r-- | libexec/ld.so/loader.c | 6 | ||||
-rw-r--r-- | libexec/ld.so/mips/rtld_machine.c | 16 | ||||
-rw-r--r-- | libexec/ld.so/powerpc/rtld_machine.c | 16 | ||||
-rw-r--r-- | libexec/ld.so/resolve.c | 26 | ||||
-rw-r--r-- | libexec/ld.so/resolve.h | 10 | ||||
-rw-r--r-- | libexec/ld.so/sparc/rtld_machine.c | 16 | ||||
-rw-r--r-- | libexec/ld.so/sparc64/rtld_machine.c | 16 |
12 files changed, 90 insertions, 74 deletions
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c index b42428cbcb6..6c2c80341b1 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.29 2003/09/05 03:56:58 drahn Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.30 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -109,7 +109,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) case R_TYPE(REFQUAD): ooff = _dl_find_symbol_bysym(object, ELF64_R_SYM(relas->r_info), _dl_objects, &this, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, sym->st_size); if (this == NULL) goto resolve_failed; @@ -134,7 +134,7 @@ _dl_printf("unaligned RELATIVE: %p type: %d %s 0x%lx -> 0x%lx\n", r_addr, break; case R_TYPE(JMP_SLOT): ooff = _dl_find_symbol(symn, _dl_objects, &this, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) goto resolve_failed; @@ -143,7 +143,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_bysym(object, ELF64_R_SYM(relas->r_info), _dl_objects, &this, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, sym->st_size); if (this == NULL) goto resolve_failed; @@ -197,7 +197,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, _dl_objects, &this, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); @@ -241,13 +241,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_size = ooff + this->st_value - object->got_addr; @@ -255,13 +255,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) plt_addr = NULL; object->plt_size = 0; this = NULL; - ooff = _dl_find_symbol("__plt_start", object, &this, + ooff = _dl_find_symbol("__plt_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) plt_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__plt_end", object, &this, + ooff = _dl_find_symbol("__plt_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); 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 d930b21b94c..5eb697f1584 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.5 2004/02/23 20:52:04 deraadt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.6 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 2002,2004 Dale Rahn @@ -246,7 +246,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz) this = NULL; ooff = _dl_find_symbol_bysym(object, ELF_R_SYM(rels->r_info), _dl_objects, - &this, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| + &this,NULL,SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JUMP_SLOT))? SYM_PLT:SYM_NOTPLT), sym->st_size); @@ -276,7 +276,7 @@ resolve_failed: Elf_Addr soff; soff = _dl_find_symbol(symn, object->next, &srcsym, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND| + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT:SYM_NOTPLT), size, object); if (srcsym == NULL) @@ -364,7 +364,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, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); @@ -415,13 +415,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); 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 32a34956c1b..4e199cc057f 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.4 2004/05/25 15:56:18 deraadt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.5 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 2004 Dale Rahn @@ -247,7 +247,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz) this = NULL; ooff = _dl_find_symbol_bysym(object, ELF_R_SYM(rels->r_info), - _dl_objects, &this, + _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT : SYM_NOTPLT), @@ -281,7 +281,7 @@ resolve_failed: Elf_Addr soff; soff = _dl_find_symbol(symn, object->next, &srcsym, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, size, object); if (srcsym == NULL) goto resolve_failed; @@ -358,13 +358,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_size = ooff + this->st_value - object->got_addr; @@ -419,7 +419,7 @@ _dl_bind(elf_object_t *object, int relidx) sym += ELF_R_SYM(rel->r_info); symn = object->dyn.strtab + sym->st_name; - ooff = _dl_find_symbol(symn, _dl_objects, &this, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c index fd1a9e3a671..c1bff3e21ab 100644 --- a/libexec/ld.so/dlfcn.c +++ b/libexec/ld.so/dlfcn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dlfcn.c,v 1.35 2004/05/25 15:56:18 deraadt Exp $ */ +/* $OpenBSD: dlfcn.c,v 1.36 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -137,7 +137,7 @@ dlsym(void *handle, const char *name) return(0); } - retval = (void *)_dl_find_symbol(name, object, &sym, + retval = (void *)_dl_find_symbol(name, object, &sym, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_NOTPLT, 0, object); if (sym != NULL) retval += sym->st_value; diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c index 4d6f80023a0..a4737065043 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.14 2004/05/25 15:56:18 deraadt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.15 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -239,7 +239,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz) this = NULL; ooff = _dl_find_symbol_bysym(object, ELF_R_SYM(rels->r_info), _dl_objects, - &this, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| + &this,NULL,SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JUMP_SLOT))? SYM_PLT:SYM_NOTPLT), sym->st_size); @@ -269,7 +269,7 @@ resolve_failed: Elf_Addr soff; soff = _dl_find_symbol(symn, object->next, &srcsym, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND| + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT:SYM_NOTPLT), size, object); if (srcsym == NULL) @@ -367,7 +367,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, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); @@ -417,13 +417,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); 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 a7b50098fe6..3dd23776a06 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.76 2004/05/25 15:56:18 deraadt Exp $ */ +/* $OpenBSD: loader.c,v 1.77 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -406,7 +406,7 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data) Elf_Addr ooff; sym = NULL; - ooff = _dl_find_symbol("atexit", _dl_objects, &sym, + ooff = _dl_find_symbol("atexit", _dl_objects, &sym, NULL, SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, dyn_obj); if (sym == NULL) _dl_printf("cannot find atexit, destructors will not be run!\n"); @@ -733,7 +733,7 @@ _dl_fixup_user_env(void) dummy_obj.load_name = "ld.so"; sym = NULL; - ooff = _dl_find_symbol("environ", _dl_objects, &sym, + ooff = _dl_find_symbol("environ", _dl_objects, &sym, NULL, SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, &dummy_obj); if (sym != NULL) *((char ***)(sym->st_value + ooff)) = _dl_so_envp; diff --git a/libexec/ld.so/mips/rtld_machine.c b/libexec/ld.so/mips/rtld_machine.c index 15a5356239f..1f466a3e28a 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.14 2003/09/02 15:17:51 drahn Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.15 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1998-2002 Opsycon AB, Sweden. @@ -70,7 +70,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz) if (ELF32_R_SYM(relocs->r_info) && !(ELF32_ST_BIND(sym->st_info) == STB_LOCAL && ELF32_ST_TYPE (sym->st_info) == STT_NOTYPE)) { - ooff = _dl_find_symbol(symn, _dl_objects, &this, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL | SYM_NOWARNNOTFOUND | SYM_PLT, sym->st_size, object); if (!this && ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) { @@ -157,25 +157,25 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->Dyn.info[DT_MIPS_GOTSYM - DT_LOPROC + DT_NUM]; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_size = ooff + this->st_value - object->got_addr; this = NULL; - ooff = _dl_find_symbol("__plt_start", object, &this, + ooff = _dl_find_symbol("__plt_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->plt_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__plt_end", object, &this, + ooff = _dl_find_symbol("__plt_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->plt_size = ooff + this->st_value - object->plt_addr; @@ -191,7 +191,7 @@ DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value)); if (symp->st_value == 0 || !lazy) { this = 0; ooff = _dl_find_symbol(strt + symp->st_name, - _dl_objects, &this, + _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, symp->st_size, object); if (this) @@ -202,7 +202,7 @@ DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value)); symp->st_shndx == SHN_UNDEF) { this = 0; ooff = _dl_find_symbol(strt + symp->st_name, - _dl_objects, &this, + _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, symp->st_size, object); if (this) diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c index 3212cc1c75a..70893dada8b 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.33 2003/12/03 17:00:15 drahn Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.34 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -206,7 +206,7 @@ _dl_printf("object relocation size %x, numrela %x\n", ELF32_ST_TYPE (sym->st_info) == STT_NOTYPE)) { ooff = _dl_find_symbol_bysym(object, ELF32_R_SYM(relas->r_info), _dl_objects, - &this, SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND| + &this, NULL, SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND| ((type == RELOC_JMP_SLOT) ? SYM_PLT:SYM_NOTPLT), sym->st_size); @@ -396,7 +396,7 @@ _dl_printf(" symn [%s] val 0x%x\n", symn, val); /* only look in this object */ src_loff = _dl_find_symbol_bysym(object, ELF32_R_SYM(relas->r_info), - cobj, &cpysrc, + cobj, &cpysrc, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND| ((type == RELOC_JMP_SLOT) ? SYM_PLT : SYM_NOTPLT), @@ -469,13 +469,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_size = ooff + this->st_value - object->got_addr; @@ -483,13 +483,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) plt_addr = 0; object->plt_size = 0; this = NULL; - ooff = _dl_find_symbol("__plt_start", object, &this, + ooff = _dl_find_symbol("__plt_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) plt_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__plt_end", object, &this, + ooff = _dl_find_symbol("__plt_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->plt_size = ooff + this->st_value - plt_addr; @@ -573,7 +573,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, _dl_objects, &this, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c index 610e43dacc8..871b5a0af53 100644 --- a/libexec/ld.so/resolve.c +++ b/libexec/ld.so/resolve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.c,v 1.22 2004/05/25 15:56:18 deraadt Exp $ */ +/* $OpenBSD: resolve.c,v 1.23 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -194,33 +194,43 @@ int _dl_symcachestat_lookups; Elf_Addr _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx, - elf_object_t *startlook, const Elf_Sym **ref, int flags, int req_size) + elf_object_t *startlook, const Elf_Sym **ref, const elf_object_t **pobj, + int flags, int req_size) { Elf_Addr ret; const Elf_Sym *sym; const char *symn; + const elf_object_t *sobj; _dl_symcachestat_lookups ++; if ((_dl_symcache != NULL) && (symidx < req_obj->nchains) && + (_dl_symcache[symidx].obj != NULL) && (_dl_symcache[symidx].sym != NULL) && (_dl_symcache[symidx].flags == flags)) { _dl_symcachestat_hits++; + sobj = _dl_symcache[symidx].obj; *ref = _dl_symcache[symidx].sym; - return _dl_symcache[symidx].offset; + if (pobj) + *pobj = sobj; + return sobj->load_offs; } sym = req_obj->dyn.symtab; sym += symidx; symn = req_obj->dyn.strtab + sym->st_name; - ret = _dl_find_symbol(symn, startlook, ref, flags, req_size, req_obj); + ret = _dl_find_symbol(symn, startlook, ref, &sobj, + flags, req_size, req_obj); + + if (pobj) + *pobj = sobj; if ((_dl_symcache != NULL) && (symidx < req_obj->nchains)) { _dl_symcache[symidx].sym = *ref; - _dl_symcache[symidx].offset = ret; + _dl_symcache[symidx].obj = sobj; _dl_symcache[symidx].flags = flags; } @@ -229,7 +239,8 @@ _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx, Elf_Addr _dl_find_symbol(const char *name, elf_object_t *startlook, - const Elf_Sym **ref, int flags, int req_size, elf_object_t *req_obj) + const Elf_Sym **ref, const elf_object_t **pobj, + int flags, int req_size, elf_object_t *req_obj) { const Elf_Sym *weak_sym = NULL; unsigned long h = 0; @@ -297,6 +308,9 @@ found: object->load_name, name); } + if (pobj) + *pobj = object; + return (object->load_offs); } diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h index 49c0e6f6740..15973beb419 100644 --- a/libexec/ld.so/resolve.h +++ b/libexec/ld.so/resolve.h @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.h,v 1.29 2003/09/04 19:33:48 drahn Exp $ */ +/* $OpenBSD: resolve.h,v 1.30 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -144,9 +144,11 @@ 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, elf_object_t *object); + const Elf_Sym **ref, const elf_object_t **pobj, + int flags, int sym_size, elf_object_t *object); Elf_Addr _dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx, - elf_object_t *startlook, const Elf_Sym **ref, int flags, int req_size); + elf_object_t *startlook, const Elf_Sym **ref, const elf_object_t **pobj, + int flags, int req_size); /* * defines for _dl_find_symbol() flag field, three bits of meaning * myself - clear: search all objects, set: search only this object @@ -213,8 +215,8 @@ extern char *_dl_debug; /* symbol lookup cache */ typedef struct sym_cache { + const elf_object_t *obj; const Elf_Sym *sym; - Elf_Addr offset; int flags; } sym_cache; diff --git a/libexec/ld.so/sparc/rtld_machine.c b/libexec/ld.so/sparc/rtld_machine.c index 3b70e8e2f49..5a215987b59 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.21 2004/05/25 15:56:18 deraadt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.22 2004/05/25 18:07:20 mickey Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -253,7 +253,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) this = NULL; ooff = _dl_find_symbol_bysym(object, ELF_R_SYM(relas->r_info), - _dl_objects, &this, + _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JMP_SLOT)) ? SYM_PLT : SYM_NOTPLT), @@ -280,7 +280,7 @@ resolve_failed: Elf_Addr soff; soff = _dl_find_symbol(symn, object->next, &srcsym, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND| + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JMP_SLOT)) ? SYM_PLT : SYM_NOTPLT), size, object); if (srcsym == NULL) @@ -341,7 +341,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, _dl_objects, &this, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); @@ -413,13 +413,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_size = ooff + this->st_value - object->got_addr; @@ -427,13 +427,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) plt_addr = 0; object->plt_size = 0; this = NULL; - ooff = _dl_find_symbol("__plt_start", object, &this, + ooff = _dl_find_symbol("__plt_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) plt_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__plt_end", object, &this, + ooff = _dl_find_symbol("__plt_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); 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 debd7b2b4a7..9d0db1b5ea8 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.32 2004/05/25 15:56:19 deraadt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.33 2004/05/25 18:07:21 mickey Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -274,7 +274,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) this = NULL; ooff = _dl_find_symbol_bysym(object, ELF_R_SYM(relas->r_info), - _dl_objects, &this, + _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| ((type == R_TYPE(JMP_SLOT)) ? SYM_PLT : SYM_NOTPLT), @@ -305,7 +305,7 @@ resolve_failed: Elf_Addr soff; soff = _dl_find_symbol(symn, object->next, &srcsym, - SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, + NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_NOTPLT, size, object); if (srcsym == NULL) goto resolve_failed; @@ -633,7 +633,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, + ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object); if (this == NULL) { _dl_printf("lazy binding failed!\n"); @@ -706,13 +706,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) object->got_addr = NULL; object->got_size = 0; this = NULL; - ooff = _dl_find_symbol("__got_start", object, &this, + ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__got_end", object, &this, + ooff = _dl_find_symbol("__got_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->got_size = ooff + this->st_value - object->got_addr; @@ -720,13 +720,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) plt_addr = 0; object->plt_size = 0; this = NULL; - ooff = _dl_find_symbol("__plt_start", object, &this, + ooff = _dl_find_symbol("__plt_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) plt_addr = ooff + this->st_value; this = NULL; - ooff = _dl_find_symbol("__plt_end", object, &this, + ooff = _dl_find_symbol("__plt_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) object->plt_size = ooff + this->st_value - plt_addr; |