aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--elf/dl-lookup.c14
-rw-r--r--elf/dl-reloc.c4
-rw-r--r--elf/dl-runtime.c2
-rw-r--r--elf/dlsym.c4
-rw-r--r--elf/do-rel.h11
-rw-r--r--elf/link.h7
-rw-r--r--elf/rtld.c2
-rw-r--r--sysdeps/i386/dl-machine.h4
-rw-r--r--sysdeps/m68k/dl-machine.h4
-rw-r--r--sysdeps/stub/dl-machine.h9
11 files changed, 50 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index e660675..a50a266 100644
--- 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.
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index cb337d4..90c9b6a 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -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))
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index b7d484d..46fc4c4 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -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;
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index 3be90ca..941a306 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -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;
diff --git a/elf/dlsym.c b/elf/dlsym.c
index 0441e54..cc50650 100644
--- a/elf/dlsym.c
+++ b/elf/dlsym.c
@@ -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. */
diff --git a/elf/do-rel.h b/elf/do-rel.h
index 72e7d01..a265550 100644
--- a/elf/do-rel.h
+++ b/elf/do-rel.h
@@ -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);
diff --git a/elf/link.h b/elf/link.h
index bdcfcf2..cd75263 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -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. */
diff --git a/elf/rtld.c b/elf/rtld.c
index edd9c51..157cde5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -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);
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 8f72073..4e0806f 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -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
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index 8cbb977..aa1f19e 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -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
diff --git a/sysdeps/stub/dl-machine.h b/sysdeps/stub/dl-machine.h
index d922723..73943f1 100644
--- a/sysdeps/stub/dl-machine.h
+++ b/sysdeps/stub/dl-machine.h
@@ -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. */