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/arch/mips Actually do lazy binding on this...



details:   https://anonhg.NetBSD.org/src/rev/fdf440c94386
branches:  trunk
changeset: 536338:fdf440c94386
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Fri Sep 13 16:03:20 2002 +0000

description:
Actually do lazy binding on this platform.

diffstat:

 libexec/ld.elf_so/arch/mips/mips_reloc.c |  56 ++++++++++++++-----------------
 1 files changed, 25 insertions(+), 31 deletions(-)

diffs (101 lines):

diff -r 1d8f13b0d82e -r fdf440c94386 libexec/ld.elf_so/arch/mips/mips_reloc.c
--- a/libexec/ld.elf_so/arch/mips/mips_reloc.c  Fri Sep 13 15:56:37 2002 +0000
+++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c  Fri Sep 13 16:03:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_reloc.c,v 1.25 2002/09/13 04:09:49 mycroft Exp $  */
+/*     $NetBSD: mips_reloc.c,v 1.26 2002/09/13 16:03:20 mycroft Exp $  */
 
 /*
  * Copyright 1997 Michael L. Hitch <mhitch%montana.edu@localhost>
@@ -49,15 +49,17 @@
        const Obj_Entry *obj = (Obj_Entry *)(u[1] & 0x7fffffff);
        const Elf_Sym *def;
        const Obj_Entry *defobj;
+       Elf_Addr new_value;
 
        def = _rtld_find_symdef(a0, obj, &defobj, true);
-       if (def) {
-               u[obj->local_gotno + a0 - obj->gotsym] = (Elf_Addr)
-                   (def->st_value + defobj->relocbase);
-               return((caddr_t)(def->st_value + defobj->relocbase));
-       }
+       if (def == NULL)
+               return(NULL);   /* XXX */
 
-       return(NULL);   /* XXX */
+       new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       rdbg(("bind now/fixup in %s --> new=%p",
+           defobj->strtab + def->st_name, (void *)new_value));
+       u[obj->local_gotno + a0 - obj->gotsym] = new_value;
+       return ((caddr_t)new_value);
 }
 
 void
@@ -140,8 +142,7 @@
                if (sym->st_shndx == SHN_UNDEF ||
                    sym->st_shndx == SHN_COMMON)
                        *got = sym->st_value + relocbase;
-               else if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
-                   *got != sym->st_value)
+               else if (ELF_ST_TYPE(sym->st_info) == STT_FUNC)
                        *got += relocbase;
                else if (ELF_ST_TYPE(sym->st_info) == STT_SECTION &&
                    ELF_ST_BIND(sym->st_info) == STB_GLOBAL) {
@@ -253,14 +254,17 @@
                rdbg((" doing got %d sym %p (%s, %x)", i - obj->gotsym, sym,
                    sym->st_name + obj->strtab, *got));
 
-               def = _rtld_find_symdef(i, obj, &defobj, true);
-               if (def == NULL)
-                       return -1;
-               if (sym->st_shndx == SHN_UNDEF ||
-                   sym->st_shndx == SHN_COMMON)
+               if (sym->st_shndx == SHN_UNDEF &&
+                   ELF_ST_BIND(sym->st_info) != STB_WEAK &&
+                   ELF_ST_TYPE(sym->st_info) == STT_FUNC)
+                       *got = sym->st_value + (Elf_Addr)obj->relocbase;
+               else if (sym->st_shndx == SHN_UNDEF ||
+                   sym->st_shndx == SHN_COMMON) {
+                       def = _rtld_find_symdef(i, obj, &defobj, true);
+                       if (def == NULL)
+                               return -1;
                        *got = def->st_value + (Elf_Addr)defobj->relocbase;
-               else if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
-                   *got != sym->st_value)
+               } else if (ELF_ST_TYPE(sym->st_info) == STT_FUNC)
                        *got += (Elf_Addr)obj->relocbase;
                else if (ELF_ST_TYPE(sym->st_info) == STT_SECTION &&
                    ELF_ST_BIND(sym->st_info) == STB_GLOBAL) {
@@ -268,8 +272,12 @@
                                *got = sym->st_value +
                                    (Elf_Addr)obj->relocbase;
                        /* else SGI stuff ignored */
-               } else
+               } else {
+                       def = _rtld_find_symdef(i, obj, &defobj, true);
+                       if (def == NULL)
+                               return -1;
                        *got = def->st_value + (Elf_Addr)defobj->relocbase;
+               }
                ++sym;
                ++got;
        }
@@ -281,18 +289,4 @@
 _rtld_relocate_plt_lazy(obj)
        const Obj_Entry *obj;
 {
-       const Elf_Rel *rel;
-
-       if (!obj->isdynamic)
-               return 0;
-
-       for (rel = obj->pltrel; rel < obj->pltrellim; rel++) {
-               Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
-
-               /* Just relocate the GOT slots pointing into the PLT */
-               *where += (Elf_Addr)obj->relocbase;
-               rdbg(("fixup !main in %s --> %p", obj->path, (void *)*where));
-       }
-
-       return 0;
 }



Home | Main Index | Thread Index | Old Index