* elf/dl-lookup.c (_dl_lookup_symbol): Arg NOSELF renamed to NOPLT.
authorRoland McGrath <roland@gnu.org>
Sun, 2 Jun 1996 21:35:43 +0000 (21:35 +0000)
committerRoland McGrath <roland@gnu.org>
Sun, 2 Jun 1996 21:35:43 +0000 (21:35 +0000)
Reject SHN_UNDEF defns iff NOPLT is nonzero.
* elf/link.h (_dl_lookup_symbol): Update prototype and comment.
* elf/dl-runtime.c (fixup): Pass 1 to _dl_lookup_symbol for NOPLT.
* elf/dlsym.c (dlsym): Pass 0.
* elf/rtld.c (dl_main): Likewise.
* elf/dl-reloc.c (_dl_relocate_object: resolve): Second arg R_OFFSET
replaced with NOPLT flag.  Pass it through to _dl_lookup_symbol.
* elf/do-rel.h (elf_dynamic_do_rel): Update prototype of RESOLVE arg.
Pass `elf_machine_pltrel_p (R->r_type)' result as NOPLT flag value.
* sysdeps/i386/dl-machine.h (elf_machine_pltrel_p): New macro.
* sysdeps/m68k/dl-machine.h (elf_machine_pltrel_p): Likewise.
* sysdeps/stub/dl-machine.h (elf_machine_pltrel_p): Likewise.

ChangeLog
elf/dl-lookup.c
elf/dl-reloc.c
elf/dl-runtime.c
elf/dlsym.c
elf/do-rel.h
elf/link.h
elf/rtld.c
sysdeps/i386/dl-machine.h
sysdeps/m68k/dl-machine.h
sysdeps/stub/dl-machine.h

index e660675dc06e8d314d01401748f8e2fd8b900584..a50a266bd85d8ae27c84c5a16819951b2e6fb258 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 Sun Jun  2 14:56:49 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
 
+       * elf/dl-lookup.c (_dl_lookup_symbol): Arg NOSELF renamed to NOPLT.
+       Reject SHN_UNDEF defns iff NOPLT is nonzero.
+       * elf/link.h (_dl_lookup_symbol): Update prototype and comment.
+       * elf/dl-runtime.c (fixup): Pass 1 to _dl_lookup_symbol for NOPLT.
+       * elf/dlsym.c (dlsym): Pass 0.
+       * elf/rtld.c (dl_main): Likewise.
+       * elf/dl-reloc.c (_dl_relocate_object: resolve): Second arg R_OFFSET
+       replaced with NOPLT flag.  Pass it through to _dl_lookup_symbol.
+       * elf/do-rel.h (elf_dynamic_do_rel): Update prototype of RESOLVE arg.
+       Pass `elf_machine_pltrel_p (R->r_type)' result as NOPLT flag value.
+       * sysdeps/i386/dl-machine.h (elf_machine_pltrel_p): New macro.
+       * sysdeps/m68k/dl-machine.h (elf_machine_pltrel_p): Likewise.
+       * sysdeps/stub/dl-machine.h (elf_machine_pltrel_p): Likewise.
+
        * login/pututline_r.c: Fix typo in sizeof for DATA_TMP alloca.
 
        * sysdeps/generic/gnu/types.h (__clock_t): New type.
index cb337d47cd762296776a61ea12ea4bdc883bce62..90c9b6a18df1617e634fe4119a4af1005e0bcc07 100644 (file)
@@ -1,5 +1,5 @@
 /* Look up a symbol in the loaded objects.
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 1995, 1996 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
@@ -22,16 +22,15 @@ Cambridge, MA 02139, USA.  */
 #include <link.h>
 #include <assert.h>
 
-/* Search loaded objects' symbol tables for a definition of
-   the symbol UNDEF_NAME.  If NOSELF is nonzero, then *REF
-   cannot satisfy the reference itself; some different binding
-   must be found.  */
+/* Search loaded objects' symbol tables for a definition of the symbol
+   UNDEF_NAME.  If NOPLT is nonzero, then a PLT entry cannot satisfy the
+   reference; some different binding must be found.  */
 
 Elf32_Addr
 _dl_lookup_symbol (const char *undef_name, const Elf32_Sym **ref,
                   struct link_map *symbol_scope,
                   const char *reference_name,
-                  int noself)
+                  int noplt)
 {
   unsigned long int hash = elf_hash (undef_name);
   struct link_map *map;
@@ -60,8 +59,7 @@ _dl_lookup_symbol (const char *undef_name, const Elf32_Sym **ref,
          const Elf32_Sym *sym = &symtab[symidx];
 
          if (sym->st_value == 0 || /* No value.  */
-             sym->st_shndx == SHN_UNDEF || /* PLT entry.  */
-             (noself && sym == *ref))  /* The reference can't define it.  */
+             (noplt && sym->st_shndx == SHN_UNDEF)) /* Unwanted PLT entry.  */
            continue;
 
          switch (ELF32_ST_TYPE (sym->st_info))
index b7d484d2df014a38b1585184cfba4e4a98b98652..46fc4c4def3c4422ac892af32ddc54a7fa2670eb 100644 (file)
@@ -60,10 +60,10 @@ _dl_relocate_object (struct link_map *l, int lazy)
       = ((void *) l->l_addr + l->l_info[DT_STRTAB]->d_un.d_ptr);
 
 
-    Elf32_Addr resolve (const Elf32_Sym **ref, Elf32_Addr r_offset)
+    Elf32_Addr resolve (const Elf32_Sym **ref, int noplt)
       {
        return _dl_lookup_symbol (strtab + (*ref)->st_name, ref, scope,
-                                 l->l_name, (*ref)->st_value == r_offset);
+                                 l->l_name, noplt);
       }
 
     real_next = l->l_next;
index 3be90caa69ce9beaeb6d9d9083c63de376cd62c0..941a306df91c730578624b4b66244fcb0d6d9c62 100644 (file)
@@ -86,7 +86,7 @@ fixup (
 
   definer = &symtab[ELF32_R_SYM (reloc->r_info)];
   loadbase = _dl_lookup_symbol (strtab + definer->st_name, &definer,
-                               scope, l->l_name, 0);
+                               scope, l->l_name, 1);
 
   /* Restore list frobnication done above for DT_SYMBOLIC.  */
   l->l_next = real_next;
index 0441e54c885d1f2be44c7fda1a1e4b08b7b1c218..cc50650fc96d770c782660a0463b0abd5d1d248b 100644 (file)
@@ -1,5 +1,5 @@
 /* dlsym -- Look up a symbol in a shared object loaded by `dlopen'.
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 1995, 1996 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
@@ -33,7 +33,7 @@ dlsym (void *handle, const char *name)
   int lose;
   void doit (void)
     {
-      loadbase = _dl_lookup_symbol (name, &ref, map, map->l_name, 1);
+      loadbase = _dl_lookup_symbol (name, &ref, map, map->l_name, 0);
     }
 
   /* Confine the symbol scope to just this map.  */
index 72e7d01cb46bd6ac115ddc2bb692bb9a1344b2ed..a265550caef54cba430f944a6a48a4bf2c4fa38b 100644 (file)
@@ -21,9 +21,9 @@ Cambridge, MA 02139, USA.  */
    `elf_dynamic_do_rel' and `elf_dynamic_do_rela'.  */
 
 #ifdef DO_RELA
-#define elf_dynamic_do_rel     elf_dynamic_do_rela
-#define        Elf32_Rel               Elf32_Rela
-#define elf_machine_rel                elf_machine_rela
+#define elf_dynamic_do_rel             elf_dynamic_do_rela
+#define        Elf32_Rel                       Elf32_Rela
+#define elf_machine_rel                        elf_machine_rela
 #endif
 
 
@@ -38,7 +38,7 @@ static inline void
 elf_dynamic_do_rel (struct link_map *map,
                    int reltag, int sztag,
                    Elf32_Addr (*resolve) (const Elf32_Sym **symbol,
-                                          Elf32_Addr r_offset),
+                                          int noplt),
                    int lazy)
 {
   const Elf32_Sym *const symtab
@@ -65,7 +65,8 @@ elf_dynamic_do_rel (struct link_map *map,
        else
          {
            if (resolve)
-             loadbase = (*resolve) (&definer, r->r_offset);
+             loadbase = (*resolve)
+               (&definer, elf_machine_pltrel_p (ELF32_R_TYPE (r->r_info)));
            else
              {
                assert (definer->st_shndx != SHN_UNDEF);
index bdcfcf27f494cc90cb9e8b016620b521a35f1f4b..cd75263e0a32f5977bf9ce1a89b519f28b86a781 100644 (file)
@@ -185,14 +185,13 @@ extern void _dl_setup_hash (struct link_map *map);
    reference; it is replaced with the defining symbol, and the base load
    address of the defining object is returned.  SYMBOL_SCOPE is the head of
    the chain used for searching.  REFERENCE_NAME should name the object
-   containing the reference; it is used in error messages.  If NOSELF is
-   nonzero, them *SYM itself cannot define the value; another binding must
-   be found.  */
+   containing the reference; it is used in error messages.  If NOPLT is
+   nonzero, then the reference must not be resolved to a PLT entry.  */
 extern Elf32_Addr _dl_lookup_symbol (const char *undef,
                                     const Elf32_Sym **sym,
                                     struct link_map *symbol_scope,
                                     const char *reference_name,
-                                    int noself);
+                                    int noplt);
 
 
 /* List of objects currently loaded.  */
index edd9c514d8994b9718484e600744aff7eea7a020..157cde51d91bdc538dc4ab1ea5c35a47ca7bf5eb 100644 (file)
@@ -318,7 +318,7 @@ of this helper program; chances are you did not intend to run this program.\n",
          const Elf32_Sym *ref = NULL;
          Elf32_Addr loadbase = _dl_lookup_symbol (_dl_argv[i], &ref,
                                                   _dl_loaded, "argument",
-                                                  1);
+                                                  0);
          char buf[20], *bp;
          buf[sizeof buf - 1] = '\0';
          bp = _itoa (ref->st_value, &buf[sizeof buf - 1], 16, 0);
index 8f720736f026af90afddf9de540267cb2681e190..4e0806fd48b5498d58829c79851d11a5c5b2e7df 100644 (file)
@@ -132,6 +132,10 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rel *reloc)
     }
 }
 
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+   PLT entries should not be allowed to define the value.  */
+#define elf_machine_pltrel_p(type) ((type) == R_386_JMP_SLOT)
+
 /* The i386 never uses Elf32_Rela relocations.  */
 #define ELF_MACHINE_NO_RELA 1
 
index 8cbb97787c670ea75c34d8a568dd46d258dea3a9..aa1f19eacb751dda0a8a36a411232c0a7103d795 100644 (file)
@@ -136,6 +136,10 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc)
     }
 }
 
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+   PLT entries should not be allowed to define the value.  */
+#define elf_machine_pltrel_p(type) ((type) == R_68K_JMP_SLOT)
+
 /* The m68k never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
 
index d9227233e4742dbcd443b41b70dea0c2fde67459..73943f1558c7065947c35f704d5a01c8295e6b90 100644 (file)
@@ -1,5 +1,5 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  Stub version.
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 1995, 1996 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
@@ -81,7 +81,7 @@ elf_machine_rel (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM],
 
 static inline void
 elf_machine_rela (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM],
-                 const Elf32_Rela *reloc, 
+                 const Elf32_Rela *reloc,
                  Elf32_Addr sym_loadaddr, const Elf32_Sym *sym)
 {
   _dl_signal_error (0, "Elf32_Rela relocation requested -- unused on "
@@ -89,6 +89,11 @@ elf_machine_rela (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM],
 }
 
 
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+   PLT entries should not be allowed to define the value.  */
+#define elf_machine_pltrel_p(type) ((type) == R_???_JMP_SLOT)
+
+
 /* Set up the loaded object described by L so its unrelocated PLT
    entries will jump to the on-demand fixup code in dl-runtime.c.  */