Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so Make immediate binding work again by actua...



details:   https://anonhg.NetBSD.org/src/rev/d2d184e79abe
branches:  trunk
changeset: 536503:d2d184e79abe
user:      junyoung <junyoung%NetBSD.org@localhost>
date:      Tue Sep 17 07:29:46 2002 +0000

description:
Make immediate binding work again by actually implementing
_rtld_relocate_plt_objects(). Note that this is for i386 only;
any efforts to make it work on other platforms are left to
those who are using them...

diffstat:

 libexec/ld.elf_so/arch/i386/mdreloc.c |  29 ++++++++++++++++++++++++++++-
 libexec/ld.elf_so/reloc.c             |   6 +++---
 libexec/ld.elf_so/rtld.h              |   3 ++-
 3 files changed, 33 insertions(+), 5 deletions(-)

diffs (78 lines):

diff -r be886ba077ab -r d2d184e79abe libexec/ld.elf_so/arch/i386/mdreloc.c
--- a/libexec/ld.elf_so/arch/i386/mdreloc.c     Tue Sep 17 07:05:09 2002 +0000
+++ b/libexec/ld.elf_so/arch/i386/mdreloc.c     Tue Sep 17 07:29:46 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mdreloc.c,v 1.14 2002/09/12 22:56:30 mycroft Exp $     */
+/*     $NetBSD: mdreloc.c,v 1.15 2002/09/17 07:29:49 junyoung Exp $    */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -204,3 +204,30 @@
        *addrp = (caddr_t)new_value;
        return 0;
 }
+
+int
+_rtld_relocate_plt_objects(const Obj_Entry *obj)
+{
+       const Elf_Rel *rel;
+       
+       for (rel = obj->pltrel; rel < obj->pltrellim; rel++) {
+               Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
+               Elf_Addr target;
+               const Elf_Sym *def;
+               const Obj_Entry *defobj;
+               
+               assert(ELF_R_TYPE(rel->r_info) == R_TYPE(JMP_SLOT));
+               
+               def = _rtld_find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
+                   true);
+               if (def == NULL)
+                       return -1;
+               target = (Elf_Addr)(defobj->relocbase + def->st_value);
+               rdbg(("bind now/fixup in %s --> old=%p new=%p",
+                   defobj->strtab + def->st_name, (void *)*where, 
+                   (void *)target));
+               if (*where != target)
+                       *where = target;
+       }
+       return 0;
+}
diff -r be886ba077ab -r d2d184e79abe libexec/ld.elf_so/reloc.c
--- a/libexec/ld.elf_so/reloc.c Tue Sep 17 07:05:09 2002 +0000
+++ b/libexec/ld.elf_so/reloc.c Tue Sep 17 07:29:46 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reloc.c,v 1.67 2002/09/13 03:09:38 mycroft Exp $        */
+/*     $NetBSD: reloc.c,v 1.68 2002/09/17 07:29:46 junyoung Exp $       */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -248,9 +248,9 @@
                }
                if (_rtld_relocate_plt_lazy(obj) < 0)
                        ok = 0;
-#if 0
+#if defined(__i386__)
                if (bind_now)
-                       if (_rtld_relocate_plt_object(obj) < 0)
+                       if (_rtld_relocate_plt_objects(obj) < 0)
                                ok = 0;
 #endif
                if (!ok)
diff -r be886ba077ab -r d2d184e79abe libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h  Tue Sep 17 07:05:09 2002 +0000
+++ b/libexec/ld.elf_so/rtld.h  Tue Sep 17 07:29:46 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld.h,v 1.49 2002/09/13 03:22:08 mycroft Exp $         */
+/*     $NetBSD: rtld.h,v 1.50 2002/09/17 07:29:47 junyoung Exp $        */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -265,6 +265,7 @@
 int _rtld_relocate_plt_lazy __P((const Obj_Entry *));
 int _rtld_relocate_plt_object __P((const Obj_Entry *, const Elf_Rela *,
     caddr_t *));
+int _rtld_relocate_plt_objects __P((const Obj_Entry *));
 
 /* search.c */
 char *_rtld_find_library __P((const char *, const Obj_Entry *));



Home | Main Index | Thread Index | Old Index