From f9f2a150e845fa19fc047285aa38e9164e42aa6a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 13 Apr 2002 07:55:02 +0000 Subject: Update. 2002-04-13 Ulrich Drepper * elf/do-lookup.h [!VERSIONED]: Add new parameter flags. Use it to check whether the caller prefers getting the most recent version of a symbol of the earliest version. * elf/dl-lookup.c: Adjust all callers of do_lookup. Change _dl_do_lookup to also take the new parameter and pass it on. Change 'explicit' parameter of _dl_lookup_symbol and _dl_lookup_versioned_symbol to flags. Adjust tests. * sysdeps/generic/ldsodefs.h: Adjust prototypes. * elf/dl-libc.c: Adjust all callers of _dl_lookup_symbol and _dl_lookup_versioned_symbol. * elf/dl-reloc.c: Likewise. * elf/dl-runtime.c: Likewise. * elf/dl-sym.c: Likewise. * sysdeps/mips/dl-machine.h: Likewise. --- elf/do-lookup.h | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'elf/do-lookup.h') diff --git a/elf/do-lookup.h b/elf/do-lookup.h index bebdb0c09f..be75fb7b00 100644 --- a/elf/do-lookup.h +++ b/elf/do-lookup.h @@ -19,10 +19,10 @@ #if VERSIONED # define FCT do_lookup_versioned -# define ARG const struct r_found_version *const version, +# define ARG const struct r_found_version *const version #else # define FCT do_lookup -# define ARG +# define ARG int flags #endif /* Inner part of the lookup functions. We return a value > 0 if we @@ -30,7 +30,7 @@ something bad happened. */ static inline int FCT (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref, - struct sym_val *result, struct r_scope_elem *scope, size_t i, ARG + struct sym_val *result, struct r_scope_elem *scope, size_t i, ARG, struct link_map *skip, int type_class) { struct link_map **list = scope->r_list; @@ -129,19 +129,34 @@ FCT (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref, continue; } #else - /* No specific version is selected. When the object file - also does not define a version we have a match. - Otherwise we accept the default version, or in case there - is only one version defined, this one version. */ + /* No specific version is selected. There are two ways we + can got here: + + - a binary which does not include versioning information + is loaded + + - dlsym() instead of dlvsym() is used to get a symbol which + might exist in more than one form + + If the library does not provide symbol version + information there is no problem at at: we simply use the + symbol if it is defined. + + These two lookups need to be handled differently if the + library defines versions. In the case of the old + unversioned application the oldest (default) version + should be used. In case of a dlsym() call the latest and + public interface should be returned. */ if (verstab != NULL) { - ElfW(Half) ndx = verstab[symidx] & 0x7fff; - if (ndx >= 2) /* map->l_versions[ndx].hash != 0) */ + if ((verstab[symidx] & 0x7fff) + >= ((flags & DL_LOOKUP_RETURN_NEWEST) ? 2 : 3)) { /* Don't accept hidden symbols. */ if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0) /* No version so far. */ versioned_sym = sym; + continue; } } -- cgit v1.2.3