about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-lookup.c54
-rw-r--r--elf/dl-reloc.c5
-rw-r--r--elf/dl-support.c4
-rw-r--r--elf/dlsym.c3
-rw-r--r--elf/dlvsym.c2
-rw-r--r--elf/link.h21
-rw-r--r--elf/rtld.c2
7 files changed, 40 insertions, 51 deletions
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 8702a85bbb..f85aa373c2 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -22,7 +22,8 @@
 #include <assert.h>
 #include <string.h>
 
-#include <dl-hash.h>
+#include "dl-hash.h"
+#include <dl-machine.h>
 #include "../stdio-common/_itoa.h"
 
 #define VERSTAG(tag)	(DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (tag))
@@ -57,10 +58,10 @@ struct sym_val
    something bad happened.  */
 static inline int
 do_lookup (const char *undef_name, unsigned long int hash,
-	   const ElfW(Sym) **ref, struct sym_val *result,
+	   const ElfW(Sym) *ref, struct sym_val *result,
 	   struct link_map *list[], size_t i, size_t n,
 	   const char *reference_name, const struct r_found_version *version,
-	   struct link_map *skip, int flags)
+	   struct link_map *skip, int reloc_type)
 {
   struct link_map *map;
 
@@ -78,7 +79,8 @@ do_lookup (const char *undef_name, unsigned long int hash,
 	continue;
 
       /* Don't search the executable when resolving a copy reloc.  */
-      if (flags & DL_LOOKUP_NOEXEC && map->l_type == lt_executable)
+      if (elf_machine_lookup_noexec_p (reloc_type) &&
+	  map->l_type == lt_executable)
 	continue;
 
       symtab = ((void *) map->l_addr + map->l_info[DT_SYMTAB]->d_un.d_ptr);
@@ -98,7 +100,7 @@ do_lookup (const char *undef_name, unsigned long int hash,
 	  const ElfW(Sym) *sym = &symtab[symidx];
 
 	  if (sym->st_value == 0 || /* No value.  */
-	      ((flags & DL_LOOKUP_NOPLT) != 0 /* Reject PLT entry.  */
+	      (elf_machine_lookup_noplt_p (reloc_type) /* Reject PLT entry.  */
 	       && sym->st_shndx == SHN_UNDEF))
 	    continue;
 
@@ -113,7 +115,7 @@ do_lookup (const char *undef_name, unsigned long int hash,
 	      continue;
 	    }
 
-	  if (sym != *ref && strcmp (strtab + sym->st_name, undef_name))
+	  if (sym != ref && strcmp (strtab + sym->st_name, undef_name))
 	    /* Not the symbol we are looking for.  */
 	    continue;
 
@@ -188,16 +190,13 @@ do_lookup (const char *undef_name, unsigned long int hash,
 }
 
 /* Search loaded objects' symbol tables for a definition of the symbol
-   UNDEF_NAME.  FLAGS is a set of flags.  If DL_LOOKUP_NOEXEC is set,
-   then don't search the executable for a definition; this used for
-   copy relocs.  If DL_LOOKUP_NOPLT is set, then a PLT entry cannot
-   satisfy the reference; some different binding must be found.  */
+   UNDEF_NAME.  */
 
 ElfW(Addr)
 _dl_lookup_symbol (const char *undef_name, const ElfW(Sym) **ref,
 		   struct link_map *symbol_scope[],
 		   const char *reference_name,
-		   int flags)
+		   int reloc_type)
 {
   const unsigned long int hash = _dl_elf_hash (undef_name);
   struct sym_val current_value = { 0, NULL };
@@ -205,9 +204,9 @@ _dl_lookup_symbol (const char *undef_name, const ElfW(Sym) **ref,
 
   /* Search the relevant loaded objects for a definition.  */
   for (scope = symbol_scope; *scope; ++scope)
-    if (do_lookup (undef_name, hash, ref, &current_value,
+    if (do_lookup (undef_name, hash, *ref, &current_value,
 		   (*scope)->l_searchlist, 0, (*scope)->l_nsearchlist,
-		   reference_name, NULL, NULL, flags))
+		   reference_name, NULL, NULL, reloc_type))
       break;
 
   if (current_value.s == NULL &&
@@ -230,8 +229,7 @@ ElfW(Addr)
 _dl_lookup_symbol_skip (const char *undef_name, const ElfW(Sym) **ref,
 			struct link_map *symbol_scope[],
 			const char *reference_name,
-			struct link_map *skip_map,
-			int flags)
+			struct link_map *skip_map)
 {
   const unsigned long int hash = _dl_elf_hash (undef_name);
   struct sym_val current_value = { 0, NULL };
@@ -243,13 +241,13 @@ _dl_lookup_symbol_skip (const char *undef_name, const ElfW(Sym) **ref,
   for (i = 0; (*scope)->l_dupsearchlist[i] != skip_map; ++i)
     assert (i < (*scope)->l_ndupsearchlist);
 
-  if (! do_lookup (undef_name, hash, ref, &current_value,
+  if (! do_lookup (undef_name, hash, *ref, &current_value,
 		   (*scope)->l_dupsearchlist, i, (*scope)->l_ndupsearchlist,
-		   reference_name, NULL, skip_map, flags))
+		   reference_name, NULL, skip_map, 0))
     while (*++scope)
-      if (do_lookup (undef_name, hash, ref, &current_value,
+      if (do_lookup (undef_name, hash, *ref, &current_value,
 		     (*scope)->l_dupsearchlist, 0, (*scope)->l_ndupsearchlist,
-		     reference_name, NULL, skip_map, flags))
+		     reference_name, NULL, skip_map, 0))
 	break;
 
   *ref = current_value.s;
@@ -266,7 +264,8 @@ ElfW(Addr)
 _dl_lookup_versioned_symbol (const char *undef_name, const ElfW(Sym) **ref,
 			     struct link_map *symbol_scope[],
 			     const char *reference_name,
-			     const struct r_found_version *version, int flags)
+			     const struct r_found_version *version,
+			     int reloc_type)
 {
   const unsigned long int hash = _dl_elf_hash (undef_name);
   struct sym_val current_value = { 0, NULL };
@@ -275,9 +274,9 @@ _dl_lookup_versioned_symbol (const char *undef_name, const ElfW(Sym) **ref,
   /* Search the relevant loaded objects for a definition.  */
   for (scope = symbol_scope; *scope; ++scope)
     {
-      int res = do_lookup (undef_name, hash, ref, &current_value,
+      int res = do_lookup (undef_name, hash, *ref, &current_value,
 			   (*scope)->l_searchlist, 0, (*scope)->l_nsearchlist,
-			   reference_name, version, NULL, flags);
+			   reference_name, version, NULL, reloc_type);
       if (res > 0)
 	break;
 
@@ -312,8 +311,7 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
 				  struct link_map *symbol_scope[],
 				  const char *reference_name,
 				  const struct r_found_version *version,
-				  struct link_map *skip_map,
-				  int flags)
+				  struct link_map *skip_map)
 {
   const unsigned long int hash = _dl_elf_hash (undef_name);
   struct sym_val current_value = { 0, NULL };
@@ -325,13 +323,13 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
   for (i = 0; (*scope)->l_dupsearchlist[i] != skip_map; ++i)
     assert (i < (*scope)->l_ndupsearchlist);
 
-  if (! do_lookup (undef_name, hash, ref, &current_value,
+  if (! do_lookup (undef_name, hash, *ref, &current_value,
 		   (*scope)->l_dupsearchlist, i, (*scope)->l_ndupsearchlist,
-		   reference_name, version, skip_map, flags))
+		   reference_name, version, skip_map, 0))
     while (*++scope)
-      if (do_lookup (undef_name, hash, ref, &current_value,
+      if (do_lookup (undef_name, hash, *ref, &current_value,
 		     (*scope)->l_dupsearchlist, 0, (*scope)->l_ndupsearchlist,
-		     reference_name, version, skip_map, flags))
+		     reference_name, version, skip_map, 0))
 	break;
 
   *ref = current_value.s;
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index d2122a8bdf..f1c43ea174 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -58,10 +58,7 @@ _dl_relocate_object (struct link_map *l, struct link_map *scope[], int lazy)
 
     /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
 #define RESOLVE(ref, version, flags) \
-    ((*ref)->st_shndx != SHN_UNDEF &&					      \
-     ELFW(ST_BIND) ((*ref)->st_info) == STB_LOCAL	      		      \
-     ? l->l_addr :			      				      \
-     (version) != NULL && (version)->hash != 0				      \
+    ((version) != NULL && (version)->hash != 0				      \
      ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, (ref), scope,   \
 				    l->l_name, (version), (flags))	      \
      : _dl_lookup_symbol (strtab + (*ref)->st_name, (ref), scope,	      \
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 593f96749b..5c70b4f263 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -1,5 +1,5 @@
 /* Support for dynamic linking code in static libc.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -62,7 +62,7 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
   int fd = __open (file, O_RDONLY);
   if (fd < 0)
     return NULL;
-  if (__fstat (fd, &st) < 0)
+  if (__fxstat (_STAT_VER, fd, &st) < 0)
     result = NULL;
   else
     {
diff --git a/elf/dlsym.c b/elf/dlsym.c
index 73f6e86475..d05619bfb4 100644
--- a/elf/dlsym.c
+++ b/elf/dlsym.c
@@ -53,8 +53,7 @@ RTLD_NEXT used in code not dynamically loaded"));
 	  while (l->l_loader)
 	    l = l->l_loader;
 
-	  loadbase = _dl_lookup_symbol_skip
-	    (name, &ref, &_dl_loaded, NULL, l, 0);
+	  loadbase = _dl_lookup_symbol_skip (name, &ref, &_dl_loaded, NULL, l);
 	}
       else
 	{
diff --git a/elf/dlvsym.c b/elf/dlvsym.c
index 922a6eed1f..b3d4c1aeee 100644
--- a/elf/dlvsym.c
+++ b/elf/dlvsym.c
@@ -57,7 +57,7 @@ RTLD_NEXT used in code not dynamically loaded"));
 	    l = l->l_loader;
 
 	  loadbase = _dl_lookup_versioned_symbol_skip
-	    (name, &ref, &_dl_loaded, NULL, &version, l, 0);
+	    (name, &ref, &_dl_loaded, NULL, &version, l);
 	}
       else
 	{
diff --git a/elf/link.h b/elf/link.h
index 62bf74c23b..3934aed8e2 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -290,18 +290,15 @@ extern void _dl_close (struct link_map *map);
    null-terminated list of object scopes to search; each object's
    l_searchlist (i.e. the segment of the dependency tree starting at that
    object) is searched in turn.  REFERENCE_NAME should name the object
-   containing the reference; it is used in error messages.  FLAGS is a
-   set of flags:  */
-#define DL_LOOKUP_NOEXEC 1	/* Don't search the executable for a
-				   definition; this is used for copy
-				   relocs. */
-#define DL_LOOKUP_NOPLT 2	/* The reference must not be resolved
-				   to a PLT entry.  */
+   containing the reference; it is used in error messages.
+   RELOC_TYPE is a machine-dependent reloc type, which is passed to
+   the `elf_machine_lookup_*_p' macros in dl-machine.h to affect which
+   symbols can be chosen.  */
 extern ElfW(Addr) _dl_lookup_symbol (const char *undef,
 				     const ElfW(Sym) **sym,
 				     struct link_map *symbol_scope[],
 				     const char *reference_name,
-				     int flags);
+				     int reloc_type);
 
 /* Lookup versioned symbol.  */
 extern ElfW(Addr) _dl_lookup_versioned_symbol (const char *undef,
@@ -309,15 +306,14 @@ extern ElfW(Addr) _dl_lookup_versioned_symbol (const char *undef,
 					       struct link_map *symbol_scope[],
 					       const char *reference_name,
 					       const struct r_found_version *version,
-					       int flags);
+					       int reloc_type);
 
 /* For handling RTLD_NEXT we must be able to skip shared objects.  */
 extern ElfW(Addr) _dl_lookup_symbol_skip (const char *undef,
 					  const ElfW(Sym) **sym,
 					  struct link_map *symbol_scope[],
 					  const char *reference_name,
-					  struct link_map *skip_this,
-					  int flags);
+					  struct link_map *skip_this);
 
 /* For handling RTLD_NEXT with versioned symbols we must be able to
    skip shared objects.  */
@@ -326,8 +322,7 @@ extern ElfW(Addr) _dl_lookup_versioned_symbol_skip (const char *undef,
 						    struct link_map *symbol_scope[],
 						    const char *reference_name,
 						    const struct r_found_version *version,
-						    struct link_map *skip_this,
-						    int flags);
+						    struct link_map *skip_this);
 
 /* Look up symbol NAME in MAP's scope and return its run-time address.  */
 extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name);
diff --git a/elf/rtld.c b/elf/rtld.c
index 84ab37942b..295a6aed7d 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -518,7 +518,7 @@ of this helper program; chances are you did not intend to run this program.\n",
 	    ElfW(Addr) loadbase = _dl_lookup_symbol (_dl_argv[i], &ref,
 						     &_dl_default_scope[2],
 						     "argument",
-						     DL_LOOKUP_NOPLT);
+						     ELF_MACHINE_RELOC_NOPLT);
 	    char buf[20], *bp;
 	    buf[sizeof buf - 1] = '\0';
 	    bp = _itoa (ref->st_value, &buf[sizeof buf - 1], 16, 0);