aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-07-14 11:39:25 +0000
committerRoland McGrath <roland@gnu.org>1996-07-14 11:39:25 +0000
commitf51d1dfd35f793488ee32c8226cb8955ed75acbe (patch)
tree0a157b3355be9569bd6217a20218e2fedd6f42d7 /elf
parentc928de790200bc7a81224377d35a91a6103387de (diff)
downloadglibc-f51d1dfd35f793488ee32c8226cb8955ed75acbe.zip
glibc-f51d1dfd35f793488ee32c8226cb8955ed75acbe.tar.gz
glibc-f51d1dfd35f793488ee32c8226cb8955ed75acbe.tar.bz2
* elf/dl-reloc.c: Include "dynamic-link.h" at file scope.
* elf/rtld.c: Include <string.h>. * elf/dynamic-link.h (ELF_DYNAMIC_DO_REL, ELF_DYNAMIC_DO_RELA, ELF_DYNAMIC_RELOCATE): No longer take RESOLVE argument. Conditionalize defns on [RESOLVE]. * elf/do-rel.h (elf_dynamic_do_rel): Likewise. * sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise. Instead use RESOLVE macro with same args. (elf_machine_rel): Conditionalize defn on [RESOLVE]. * elf/dl-reloc.c (RESOLVE): New macro, define before including "dynamic-link.h". It replaces `resolve' local function. * elf/dl-runtime.c: Likewise. * elf/rtld.c: Likewise.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-reloc.c16
-rw-r--r--elf/dl-runtime.c21
-rw-r--r--elf/do-rel.h12
-rw-r--r--elf/dynamic-link.h26
-rw-r--r--elf/rtld.c4
5 files changed, 41 insertions, 38 deletions
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index e6778e7..5adf0f6 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -24,7 +24,6 @@ Cambridge, MA 02139, USA. */
#include <errno.h>
#include "dynamic-link.h"
-
void
_dl_relocate_object (struct link_map *l, struct link_map *scope[], int lazy)
{
@@ -56,15 +55,14 @@ _dl_relocate_object (struct link_map *l, struct link_map *scope[], int lazy)
const char *strtab /* String table object symbols. */
= ((void *) l->l_addr + l->l_info[DT_STRTAB]->d_un.d_ptr);
- ElfW(Addr) resolve (const ElfW(Sym) **ref,
- ElfW(Addr) reloc_addr, int noplt)
- {
- /* Look up the referenced symbol in the specified scope. */
- return _dl_lookup_symbol (strtab + (*ref)->st_name, ref, scope,
- l->l_name, reloc_addr, noplt);
- }
- ELF_DYNAMIC_RELOCATE (l, lazy, resolve);
+ /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
+#define RESOLVE(ref, reloc_addr, noplt) \
+ (_dl_lookup_symbol (strtab + (*ref)->st_name, ref, scope, \
+ l->l_name, reloc_addr, noplt))
+
+#include "dynamic-link.h"
+ ELF_DYNAMIC_RELOCATE (l, lazy);
}
/* Set up the PLT so its unrelocated entries will jump to
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index cdacd75..2785592 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -18,7 +18,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <link.h>
-#include "dynamic-link.h"
/* The global scope we will use for symbol lookups.
@@ -68,6 +67,8 @@ _dl_object_relocation_scope (struct link_map *l)
}
}
+#include "dynamic-link.h"
+
/* Figure out the right type, Rel or Rela. */
#define elf_machine_rel 1
#define elf_machine_rela 2
@@ -118,14 +119,16 @@ fixup (
/* Set up the scope to find symbols referenced by this object. */
struct link_map **scope = _dl_object_relocation_scope (l);
- /* Perform the specified relocation. */
- ElfW(Addr) resolve (const ElfW(Sym) **ref,
- ElfW(Addr) reloc_addr, int noplt)
- {
- return _dl_lookup_symbol (strtab + (*ref)->st_name, ref,
- scope, l->l_name, reloc_addr, noplt);
- }
- elf_machine_relplt (l, reloc, &symtab[ELFW(R_SYM) (reloc->r_info)], resolve);
+ {
+ /* This macro is used as a callback from the elf_machine_relplt code. */
+#define RESOLVE(ref, reloc_addr, noplt) \
+ (_dl_lookup_symbol (strtab + (*ref)->st_name, ref, scope, \
+ l->l_name, reloc_addr, noplt))
+#include "dynamic-link.h"
+
+ /* Perform the specified relocation. */
+ elf_machine_relplt (l, reloc, &symtab[ELFW(R_SYM) (reloc->r_info)]);
+ }
*_dl_global_scope_end = NULL;
diff --git a/elf/do-rel.h b/elf/do-rel.h
index ebf2e84..25da592 100644
--- a/elf/do-rel.h
+++ b/elf/do-rel.h
@@ -28,17 +28,13 @@ Cambridge, MA 02139, USA. */
/* Perform the relocations in MAP on the running program image as specified
- by RELTAG, SZTAG. *RESOLVE is called to resolve symbol values; it
- modifies its argument pointer to point to the defining symbol, and
- returns the base load address of the defining object. If LAZY is
- nonzero, this is the first pass on PLT relocations; they should be set
- up to call _dl_runtime_resolve, rather than fully resolved now. */
+ by RELTAG, SZTAG. If LAZY is nonzero, this is the first pass on PLT
+ relocations; they should be set up to call _dl_runtime_resolve, rather
+ than fully resolved now. */
static inline void
elf_dynamic_do_rel (struct link_map *map,
int reltag, int sztag,
- ElfW(Addr) (*resolve) (const ElfW(Sym) **symbol,
- ElfW(Addr) reloc_addr, int noplt),
int lazy)
{
const ElfW(Sym) *const symtab
@@ -53,7 +49,7 @@ elf_dynamic_do_rel (struct link_map *map,
elf_machine_lazy_rel (map, r);
else
for (; r < end; ++r)
- elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], resolve);
+ elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)]);
}
#undef elf_dynamic_do_rel
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
index b69cb3f..45b6b2d 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -56,6 +56,8 @@ elf_get_dynamic_info (ElfW(Dyn) *dyn, ElfW(Dyn) *info[DT_NUM + DT_PROCNUM])
info[DT_PLTREL]->d_un.d_val == DT_RELA);
}
+#ifdef RESOLVE
+
/* Get the definitions of `elf_dynamic_do_rel' and `elf_dynamic_do_rela'.
These functions are almost identical, so we use cpp magic to avoid
duplicating their code. It cannot be done in a more general function
@@ -63,31 +65,33 @@ elf_get_dynamic_info (ElfW(Dyn) *dyn, ElfW(Dyn) *info[DT_NUM + DT_PROCNUM])
#if ! ELF_MACHINE_NO_REL
#include "do-rel.h"
-#define ELF_DYNAMIC_DO_REL(map, lazy, resolve) \
+#define ELF_DYNAMIC_DO_REL(map, lazy) \
if ((map)->l_info[DT_REL]) \
- elf_dynamic_do_rel ((map), DT_REL, DT_RELSZ, (resolve), 0); \
+ elf_dynamic_do_rel ((map), DT_REL, DT_RELSZ, 0); \
if ((map)->l_info[DT_PLTREL] && \
(map)->l_info[DT_PLTREL]->d_un.d_val == DT_REL) \
- elf_dynamic_do_rel ((map), DT_JMPREL, DT_PLTRELSZ, (resolve), (lazy));
+ elf_dynamic_do_rel ((map), DT_JMPREL, DT_PLTRELSZ, (lazy));
#else
-#define ELF_DYNAMIC_DO_REL(map, lazy, resolve) /* Nothing to do. */
+#define ELF_DYNAMIC_DO_REL(map, lazy) /* Nothing to do. */
#endif
#if ! ELF_MACHINE_NO_RELA
#define DO_RELA
#include "do-rel.h"
-#define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) \
+#define ELF_DYNAMIC_DO_RELA(map, lazy) \
if ((map)->l_info[DT_RELA]) \
- elf_dynamic_do_rela ((map), DT_RELA, DT_RELASZ, (resolve), 0); \
+ elf_dynamic_do_rela ((map), DT_RELA, DT_RELASZ, 0); \
if ((map)->l_info[DT_PLTREL] && \
(map)->l_info[DT_PLTREL]->d_un.d_val == DT_RELA) \
- elf_dynamic_do_rela ((map), DT_JMPREL, DT_PLTRELSZ, (resolve), (lazy));
+ elf_dynamic_do_rela ((map), DT_JMPREL, DT_PLTRELSZ, (lazy));
#else
-#define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) /* Nothing to do. */
+#define ELF_DYNAMIC_DO_RELA(map, lazy) /* Nothing to do. */
#endif
/* This can't just be an inline function because GCC is too dumb
to inline functions containing inlines themselves. */
-#define ELF_DYNAMIC_RELOCATE(map, lazy, resolve) \
- do { ELF_DYNAMIC_DO_REL ((map), (lazy), (resolve)); \
- ELF_DYNAMIC_DO_RELA ((map), (lazy), (resolve)); } while (0)
+#define ELF_DYNAMIC_RELOCATE(map, lazy) \
+ do { ELF_DYNAMIC_DO_REL ((map), (lazy)); \
+ ELF_DYNAMIC_DO_RELA ((map), (lazy)); } while (0)
+
+#endif
diff --git a/elf/rtld.c b/elf/rtld.c
index 2e23d9c..1058d87 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -20,6 +20,7 @@ Cambridge, MA 02139, USA. */
#include <link.h>
#include <stddef.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/mman.h> /* Check if MAP_ANON is defined. */
#include "../stdio-common/_itoa.h"
@@ -28,6 +29,7 @@ Cambridge, MA 02139, USA. */
/* This #define produces dynamic linking inline functions for
bootstrap relocation instead of general-purpose relocation. */
#define RTLD_BOOTSTRAP
+#define RESOLVE(sym, reloc_addr, noplt) 0
#include "dynamic-link.h"
@@ -79,7 +81,7 @@ _dl_start (void *arg)
/* Relocate ourselves so we can do normal function calls and
data access using the global offset table. */
- ELF_DYNAMIC_RELOCATE (&bootstrap_map, 0, NULL);
+ ELF_DYNAMIC_RELOCATE (&bootstrap_map, 0);
/* Now life is sane; we can call functions and access global data.