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 Add LD_BIND_NOW support for sparc64.



details:   https://anonhg.NetBSD.org/src/rev/ee13f22ddf68
branches:  trunk
changeset: 572489:ee13f22ddf68
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 05 09:16:03 2005 +0000

description:
Add LD_BIND_NOW support for sparc64.

diffstat:

 libexec/ld.elf_so/arch/sparc64/mdreloc.c |  57 +++++++++++++++++++++++++++----
 libexec/ld.elf_so/reloc.c                |   7 ++-
 2 files changed, 53 insertions(+), 11 deletions(-)

diffs (125 lines):

diff -r 27c93827d715 -r ee13f22ddf68 libexec/ld.elf_so/arch/sparc64/mdreloc.c
--- a/libexec/ld.elf_so/arch/sparc64/mdreloc.c  Wed Jan 05 09:15:19 2005 +0000
+++ b/libexec/ld.elf_so/arch/sparc64/mdreloc.c  Wed Jan 05 09:16:03 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mdreloc.c,v 1.34 2003/07/24 10:12:29 skrll Exp $       */
+/*     $NetBSD: mdreloc.c,v 1.35 2005/01/05 09:16:03 martin Exp $      */
 
 /*-
  * Copyright (c) 2000 Eduardo Horvath.
@@ -223,6 +223,8 @@
 #define        MOV_g1_o1       0x92100001
 
 void _rtld_install_plt(Elf_Word *pltgot, Elf_Addr proc);
+static inline int _rtld_relocate_plt_object(const Obj_Entry *obj,
+    const Elf_Rela *rela, Elf_Addr *tp);
 
 void
 _rtld_install_plt(Elf_Word *pltgot, Elf_Addr proc)
@@ -447,10 +449,8 @@
 _rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
 {
        const Elf_Rela *rela = obj->pltrela + reloff;
-       const Elf_Sym *def;
-       const Obj_Entry *defobj;
-       Elf_Word *where;
-       Elf_Addr value, offset;
+       Elf_Addr result;
+       int err;
 
        if (ELF_R_TYPE(obj->pltrela->r_info) == R_TYPE(JMP_SLOT)) {
                /*
@@ -471,7 +471,45 @@
                rela -= 4;
        }
 
-       where = (Elf_Word *)(obj->relocbase + rela->r_offset);
+       err = _rtld_relocate_plt_object(obj, rela, &result);
+       if (err)
+               _rtld_die();
+
+       return (caddr_t)result;
+}
+
+int
+_rtld_relocate_plt_objects(const Obj_Entry *obj)
+{
+       const Elf_Rela *rela;
+
+       rela = obj->pltrela;
+
+       /*
+        * Check for first four reserved entries - and skip them.
+        * See above for details.
+        */
+       if (ELF_R_TYPE(obj->pltrela->r_info) != R_TYPE(JMP_SLOT))
+               rela += 4;
+
+       for (; rela < obj->pltrelalim; rela++)
+               if (_rtld_relocate_plt_object(obj, rela, NULL) < 0)
+                       return -1;
+
+       return 0;
+}
+
+/*
+ * New inline function that is called by _rtld_relocate_plt_object and
+ * _rtld_bind
+ */
+static inline int
+_rtld_relocate_plt_object(const Obj_Entry *obj, const Elf_Rela *rela, Elf_Addr *tp)
+{
+       Elf_Word *where = (Elf_Word *)(obj->relocbase + rela->r_offset);
+       const Elf_Sym *def;
+       const Obj_Entry *defobj;
+       Elf_Addr value, offset;
 
        /* Fully resolve procedure addresses now */
 
@@ -479,7 +517,7 @@
 
        def = _rtld_find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true);
        if (def == NULL)
-               _rtld_die();
+               return -1;
 
        value = (Elf_Addr)(defobj->relocbase + def->st_value);
        rdbg(("bind now/fixup in %s --> new=%p", 
@@ -687,5 +725,8 @@
 
        }
 
-       return (caddr_t)value;
+       if (tp)
+               *tp = value;
+
+       return 0;
 }
diff -r 27c93827d715 -r ee13f22ddf68 libexec/ld.elf_so/reloc.c
--- a/libexec/ld.elf_so/reloc.c Wed Jan 05 09:15:19 2005 +0000
+++ b/libexec/ld.elf_so/reloc.c Wed Jan 05 09:16:03 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reloc.c,v 1.85 2004/10/22 05:39:56 skrll Exp $  */
+/*     $NetBSD: reloc.c,v 1.86 2005/01/05 09:16:03 martin Exp $         */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: reloc.c,v 1.85 2004/10/22 05:39:56 skrll Exp $");
+__RCSID("$NetBSD: reloc.c,v 1.86 2005/01/05 09:16:03 martin Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -190,7 +190,8 @@
 #if defined(__hppa__)
                bind_now = 1;
 #endif
-#if defined(__i386__) || defined(__arm__) || defined(__hppa__)
+#if defined(__i386__) || defined(__arm__) || defined(__hppa__) \
+    || defined(__sparc64__)
                if (bind_now) {
                        dbg(("doing immediate PLT binding"));
                        if (_rtld_relocate_plt_objects(obj) < 0)



Home | Main Index | Thread Index | Old Index