aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf/i386
diff options
context:
space:
mode:
authorJohn Polstra <jdp@FreeBSD.org>1999-06-25 02:53:59 +0000
committerJohn Polstra <jdp@FreeBSD.org>1999-06-25 02:53:59 +0000
commit962fdc466afdd71fb36d0c285205fd2876212b5e (patch)
treebbf11976d916320a6e9df322ff7c118598e43a8a /libexec/rtld-elf/i386
parent0099533a1c9ddd892adfce70ed08385027ebb405 (diff)
Notes
Diffstat (limited to 'libexec/rtld-elf/i386')
-rw-r--r--libexec/rtld-elf/i386/reloc.c46
-rw-r--r--libexec/rtld-elf/i386/rtld_machdep.h10
2 files changed, 30 insertions, 26 deletions
diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c
index 82c0e8e13578f..bdae9216a0f74 100644
--- a/libexec/rtld-elf/i386/reloc.c
+++ b/libexec/rtld-elf/i386/reloc.c
@@ -1,5 +1,5 @@
/*-
- * Copyright 1996-1998 John D. Polstra.
+ * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: reloc.c,v 1.1 1998/09/04 19:03:57 dfr Exp $
+ * $Id: reloc.c,v 1.2 1999/04/09 00:28:43 jdp Exp $
*/
/*
@@ -214,33 +214,29 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
int
reloc_plt(Obj_Entry *obj, bool bind_now)
{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
+ const Elf_Rel *rellim;
+ const Elf_Rel *rel;
- /* Process the PLT relocations. */
- rellim = (const Elf_Rel *) ((caddr_t) obj->pltrel + obj->pltrelsize);
- if (bind_now) {
- /* Fully resolve procedure addresses now */
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where = (Elf_Addr *)
- (obj->relocbase + rel->r_offset);
- const Elf_Sym *def;
- const Obj_Entry *defobj;
+ rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
+ for (rel = obj->pltrel; rel < rellim; rel++) {
+ Elf_Addr *where;
- assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT);
+ assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT);
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true);
- if (def == NULL)
- return -1;
+ /* Relocate the GOT slot pointing into the PLT. */
+ where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
+ *where += (Elf_Addr)obj->relocbase;
- *where = (Elf_Addr) (defobj->relocbase + def->st_value);
- }
- } else { /* Just relocate the GOT slots pointing into the PLT */
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where = (Elf_Addr *)
- (obj->relocbase + rel->r_offset);
- *where += (Elf_Addr) obj->relocbase;
- }
+ if (bind_now) { /* Fully resolve the procedure address. */
+ const Elf_Sym *def;
+ const Obj_Entry *defobj;
+
+ def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true);
+ if (def == NULL)
+ return -1;
+ reloc_jmpslot(where,
+ (Elf_Addr)(defobj->relocbase + def->st_value));
}
+ }
return 0;
}
diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h
index 89a93222c1a45..fe39d43ed530d 100644
--- a/libexec/rtld-elf/i386/rtld_machdep.h
+++ b/libexec/rtld-elf/i386/rtld_machdep.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: rtld_machdep.h,v 1.1 1999/04/09 00:28:43 jdp Exp $
*/
#ifndef RTLD_MACHDEP_H
@@ -33,4 +33,12 @@
#define rtld_dynamic(obj) \
((const Elf_Dyn *)((obj)->relocbase + (Elf_Addr)&_DYNAMIC))
+/* Fixup the jump slot at "where" to transfer control to "target". */
+#define reloc_jmpslot(where, target) \
+ do { \
+ dbg("reloc_jmpslot: *%p = %p", (void *)(where), \
+ (void *)(target)); \
+ (*(Elf_Addr *)(where) = (Elf_Addr)(target)); \
+ } while (0)
+
#endif