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 Catch up with type changes. Also:



details:   https://anonhg.NetBSD.org/src/rev/9f7e3df09c74
branches:  trunk
changeset: 495309:9f7e3df09c74
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Wed Jul 26 02:07:34 2000 +0000

description:
Catch up with type changes.  Also:
* Apply DT_PLTRELSZ to (one of) pltrel or pltrela *after* we've finished
  parsing the headers, so we know which one.
* Fix sparc64 bogons.  (It works now!)

diffstat:

 libexec/ld.elf_so/arch/sparc64/mdreloc.c |  25 +++++++++++++------------
 libexec/ld.elf_so/headers.c              |  25 ++++++++++++-------------
 libexec/ld.elf_so/reloc.c                |   8 ++++----
 libexec/ld.elf_so/rtld.c                 |  12 +++++++-----
 libexec/ld.elf_so/rtld.h                 |   4 ++--
 libexec/ld.elf_so/symbol.c               |   6 +++---
 6 files changed, 41 insertions(+), 39 deletions(-)

diffs (289 lines):

diff -r 270a66b3ef17 -r 9f7e3df09c74 libexec/ld.elf_so/arch/sparc64/mdreloc.c
--- a/libexec/ld.elf_so/arch/sparc64/mdreloc.c  Wed Jul 26 02:04:53 2000 +0000
+++ b/libexec/ld.elf_so/arch/sparc64/mdreloc.c  Wed Jul 26 02:07:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mdreloc.c,v 1.2 2000/07/18 22:33:56 eeh Exp $  */
+/*     $NetBSD: mdreloc.c,v 1.3 2000/07/26 02:07:36 mycroft Exp $      */
 
 /*-
  * Copyright (c) 2000 Eduardo Horvath.
@@ -192,7 +192,8 @@
        bool dodebug;
 {
        Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rela->r_offset);
-       Elf_Word type, value = 0, mask;
+       Elf_Word type;
+       Elf_Addr value = 0, mask;
        const Elf_Sym *def = NULL;
        const Obj_Entry *defobj = NULL;
 
@@ -236,11 +237,11 @@
                        return (-1);
 
                /* Add in the symbol's absolute address */
-               value += (Elf_Word)(defobj->relocbase + def->st_value);
+               value += (Elf_Addr)(defobj->relocbase + def->st_value);
        }
 
        if (RELOC_PC_RELATIVE(type)) {
-               value -= (Elf_Word)where;
+               value -= (Elf_Addr)where;
        }
 
        if (RELOC_BASE_RELATIVE(type)) {
@@ -263,7 +264,7 @@
                }
 #endif
                /* XXXX -- apparently we ignore the preexisting value */
-               value += (Elf_Word)(obj->relocbase);
+               value += (Elf_Addr)(obj->relocbase);
        }
 
        mask = RELOC_VALUE_BITMASK(type);
@@ -272,7 +273,7 @@
 
        if (RELOC_UNALIGNED(type)) {
                /* Handle unaligned relocations. */
-               Elf_Word tmp = 0;
+               Elf_Addr tmp = 0;
                char *ptr = (char *)where;
                int i, size = RELOC_TARGET_SIZE(type)/8;
                
@@ -287,14 +288,14 @@
                for (i=0; i<size; i++)
                        ptr[i] = ((tmp >> (8*i)) & 0xff);
 #ifdef RTLD_DEBUG_RELOC
-               value = (Elf_Word)tmp;
+               value = (Elf_Addr)tmp;
 #endif
 
        } else if (RELOC_TARGET_SIZE(type) > 32) {
                *where &= ~mask;
                *where |= value;
 #ifdef RTLD_DEBUG_RELOC
-               value = (Elf_Word)*where;
+               value = (Elf_Addr)*where;
 #endif
        } else {
                Elf32_Addr *where32 = (Elf32_Addr *)where;
@@ -302,7 +303,7 @@
                *where32 &= ~mask;
                *where32 |= value;
 #ifdef RTLD_DEBUG_RELOC
-               value = (Elf_Word)*where32;
+               value = (Elf_Addr)*where32;
 #endif
        }
 
@@ -352,7 +353,7 @@
 {
        const Elf_Sym *def;
        const Obj_Entry *defobj;
-       Elf32_Word *where = (Elf32_Word *)((Elf_Addr)obj->pltgot + rela->r_offset);
+       Elf_Word *where = (Elf_Word *)((Elf_Addr)obj->relocbase + rela->r_offset);
        Elf_Addr value, offset;
 
        if (bind_now == 0 && obj->pltgot != NULL)
@@ -590,11 +591,11 @@
 #define        JMPL_l0_o0      0x93c42000
 #define        MOV_g1_o0       0x90100001
 
-void _rtld_install_plt __P((Elf32_Word *pltgot,        Elf_Addr proc));
+void _rtld_install_plt __P((Elf_Word *pltgot,  Elf_Addr proc));
 
 void
 _rtld_install_plt(pltgot, proc)
-       Elf32_Word *pltgot;
+       Elf_Word *pltgot;
        Elf_Addr proc;
 {
        pltgot[0] = SAVE;
diff -r 270a66b3ef17 -r 9f7e3df09c74 libexec/ld.elf_so/headers.c
--- a/libexec/ld.elf_so/headers.c       Wed Jul 26 02:04:53 2000 +0000
+++ b/libexec/ld.elf_so/headers.c       Wed Jul 26 02:07:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: headers.c,v 1.7 2000/07/18 22:33:55 eeh Exp $   */
+/*     $NetBSD: headers.c,v 1.8 2000/07/26 02:07:34 mycroft Exp $       */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -64,8 +64,8 @@
        Needed_Entry  **needed_tail = &obj->needed;
        const Elf_Dyn  *dyn_rpath = NULL;
        Elf_Sword       plttype = DT_REL;
-       Elf_Word        relsz = 0, relasz = 0;
-       Elf_Word        pltrelsz = 0, pltrelasz = 0;
+       Elf_Addr        relsz = 0, relasz = 0;
+       Elf_Addr        pltrelsz = 0;
 
        for (dynp = obj->dynamic; dynp->d_tag != DT_NULL; ++dynp) {
                switch (dynp->d_tag) {
@@ -94,11 +94,7 @@
                        break;
 
                case DT_PLTRELSZ:
-                       if (plttype == DT_REL) {
-                               pltrelsz = dynp->d_un.d_val;
-                       } else {
-                               pltrelasz = dynp->d_un.d_val;
-                       }
+                       pltrelsz = dynp->d_un.d_val;
                        break;
 
                case DT_RELA:
@@ -118,7 +114,7 @@
                        plttype = dynp->d_un.d_val;
                        assert(plttype == DT_REL ||
                            plttype == DT_RELA);
-#if !defined(__sparc__) && !defined(__archv9__)
+#if !defined(__sparc__) && !defined(__archv9__) && !defined(__sparc_v9__)
                        /* 
                         * sparc v9 has both DT_PLTREL and DT_JMPREL.
                         * But they point to different things.
@@ -127,8 +123,6 @@
                        if (plttype == DT_RELA) {
                                obj->pltrela = (const Elf_RelA *) obj->pltrel;
                                obj->pltrel = NULL;
-                               pltrelasz = pltrelsz;
-                               pltrelsz = 0;
                        }
 #endif
                        break;
@@ -244,8 +238,13 @@
 
        obj->rellim = (const Elf_Rel *)((caddr_t)obj->rel + relsz);
        obj->relalim = (const Elf_RelA *)((caddr_t)obj->rela + relasz);
-       obj->pltrellim = (const Elf_Rel *)((caddr_t)obj->pltrel + pltrelsz);
-       obj->pltrelalim = (const Elf_RelA *)((caddr_t)obj->pltrela + pltrelasz);
+       if (plttype == DT_REL) {
+               obj->pltrellim = (const Elf_Rel *)((caddr_t)obj->pltrel + pltrelsz);
+               obj->pltrelalim = 0;
+       } else {
+               obj->pltrellim = 0;
+               obj->pltrelalim = (const Elf_RelA *)((caddr_t)obj->pltrela + pltrelsz);
+       }
 
        if (dyn_rpath != NULL) {
                _rtld_add_paths(&obj->rpaths, obj->strtab +
diff -r 270a66b3ef17 -r 9f7e3df09c74 libexec/ld.elf_so/reloc.c
--- a/libexec/ld.elf_so/reloc.c Wed Jul 26 02:04:53 2000 +0000
+++ b/libexec/ld.elf_so/reloc.c Wed Jul 26 02:07:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reloc.c,v 1.30 2000/07/18 22:33:55 eeh Exp $    */
+/*     $NetBSD: reloc.c,v 1.31 2000/07/26 02:07:34 mycroft Exp $        */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -673,7 +673,7 @@
                        _rtld_setup_powerpc_plt(obj);
 #endif
 #if defined(__sparc__)
-#if defined(__arch64__)
+#if defined(__arch64__) || defined(__sparc_v9__)
                        /*
                         * On sparc64 we got troubles.
                         *
@@ -692,8 +692,8 @@
                         * Oh, we need to fill out both PLT0 and PLT1.
                         */
                        {
-                               Elf32_Word *entry = (Elf32_Word *)obj->pltgot;
-                               extern void _rtld_install_plt __P((Elf32_Word *,
+                               Elf_Word *entry = (Elf_Word *)obj->pltgot;
+                               extern void _rtld_install_plt __P((Elf_Word *,
                                        Elf_Addr));
                                extern void _rtld_bind_start_0 __P((long,
                                        long));
diff -r 270a66b3ef17 -r 9f7e3df09c74 libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c  Wed Jul 26 02:04:53 2000 +0000
+++ b/libexec/ld.elf_so/rtld.c  Wed Jul 26 02:07:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld.c,v 1.38 2000/07/19 15:01:16 thorpej Exp $         */
+/*     $NetBSD: rtld.c,v 1.39 2000/07/26 02:07:35 mycroft Exp $         */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -73,7 +73,7 @@
 static void     _rtld_init __P((caddr_t, int));
 static void     _rtld_exit __P((void));
 
-Elf_Addr        _rtld __P((Elf_Word *));
+Elf_Addr        _rtld __P((Elf_Addr *));
 
 
 /*
@@ -281,7 +281,7 @@
  */
 Elf_Addr
 _rtld(sp)
-       Elf_Word *sp;
+       Elf_Addr *sp;
 {
        const AuxInfo  *pAUX_base, *pAUX_entry, *pAUX_execfd, *pAUX_phdr,
                       *pAUX_phent, *pAUX_phnum;
@@ -291,10 +291,11 @@
        char          **env;
        const AuxInfo  *aux;
        const AuxInfo  *auxp;
-       Elf_Word       *const osp = sp;
+       Elf_Addr       *const osp = sp;
        bool            bind_now = 0;
        const char     *ld_bind_now;
        const char    **argv;
+       int             argc;
        Obj_Entry       *obj;
        const char **real___progname;
        const Obj_Entry **real___mainprog_obj;
@@ -322,7 +323,8 @@
 
        sp += 2;                /* skip over return argument space */
        argv = (const char **) &sp[1];
-       sp += ((int *)sp)[0] + 2;       /* Skip over argc, arguments, and NULL
+       argc = *(int *)sp;
+       sp += 2 + argc;         /* Skip over argc, arguments, and NULL
                                 * terminator */
        env = (char **) sp;
        while (*sp++ != 0) {    /* Skip over environment, and NULL terminator */
diff -r 270a66b3ef17 -r 9f7e3df09c74 libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h  Wed Jul 26 02:04:53 2000 +0000
+++ b/libexec/ld.elf_so/rtld.h  Wed Jul 26 02:07:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld.h,v 1.26 2000/07/06 03:16:51 christos Exp $        */
+/*     $NetBSD: rtld.h,v 1.27 2000/07/26 02:07:35 mycroft Exp $         */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -278,7 +278,7 @@
 unsigned long _rtld_elf_hash __P((const char *));
 const Elf_Sym *_rtld_symlook_obj __P((const char *, unsigned long,
     const Obj_Entry *, bool));
-const Elf_Sym *_rtld_find_symdef __P((const Obj_Entry *, Elf_Word,
+const Elf_Sym *_rtld_find_symdef __P((const Obj_Entry *, Elf_Addr,
     const char *, Obj_Entry *, const Obj_Entry **, bool));
 const Elf_Sym *_rtld_symlook_list(const char *, unsigned long,
   Objlist *, const Obj_Entry **, bool in_plt);
diff -r 270a66b3ef17 -r 9f7e3df09c74 libexec/ld.elf_so/symbol.c
--- a/libexec/ld.elf_so/symbol.c        Wed Jul 26 02:04:53 2000 +0000
+++ b/libexec/ld.elf_so/symbol.c        Wed Jul 26 02:07:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: symbol.c,v 1.8 2000/07/03 03:33:52 matt Exp $   */
+/*     $NetBSD: symbol.c,v 1.9 2000/07/26 02:07:36 mycroft Exp $        */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -156,13 +156,13 @@
 const Elf_Sym *
 _rtld_find_symdef(obj_list, r_info, name, refobj, defobj_out, in_plt)
        const Obj_Entry *obj_list;
-       Elf_Word r_info;
+       Elf_Addr r_info;
        const char *name;
        Obj_Entry *refobj;
        const Obj_Entry **defobj_out;
        bool in_plt;
 {
-       Elf_Word symnum = ELF_R_SYM(r_info);
+       Elf_Addr symnum = ELF_R_SYM(r_info);
        const Elf_Sym  *ref = NULL;
        const Elf_Sym  *def;
        const Elf_Sym  *symp;



Home | Main Index | Thread Index | Old Index