about summary refs log tree commit diff
path: root/elf/do-lookup.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-04-13 07:55:02 +0000
committerUlrich Drepper <drepper@redhat.com>2002-04-13 07:55:02 +0000
commitf9f2a150e845fa19fc047285aa38e9164e42aa6a (patch)
treef03cc56b23d340150f545060f32a12dabaa5aa4b /elf/do-lookup.h
parent61bb2ef098cc1e7e598e32511915525de98ed7d1 (diff)
downloadglibc-f9f2a150e845fa19fc047285aa38e9164e42aa6a.tar.gz
glibc-f9f2a150e845fa19fc047285aa38e9164e42aa6a.tar.xz
glibc-f9f2a150e845fa19fc047285aa38e9164e42aa6a.zip
Update.
2002-04-13  Ulrich Drepper  <drepper@redhat.com>

	* 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.
Diffstat (limited to 'elf/do-lookup.h')
-rw-r--r--elf/do-lookup.h33
1 files changed, 24 insertions, 9 deletions
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;
 		}
 	    }