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 Pass down an additional flag to _rtld_relo...



details:   https://anonhg.NetBSD.org/src/rev/30c5b60eea0f
branches:  trunk
changeset: 536086:30c5b60eea0f
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Fri Sep 06 15:17:53 2002 +0000

description:
Pass down an additional flag to _rtld_relocate_nonplt_objects() which
indicates whether we're relocating ld.elf_so itself.  Use this in some places
rather than hackish tests on `dodebug'.  (The Alpha and HPPA `dodebug' tests
were actually noops, because RTLD_RELOCATE_SELF is not set, and therefore
dodebug is always true.)

diffstat:

 libexec/ld.elf_so/arch/alpha/alpha_reloc.c |  7 ++++---
 libexec/ld.elf_so/arch/arm/mdreloc.c       |  3 ++-
 libexec/ld.elf_so/arch/hppa/hppa_reloc.c   |  7 ++++---
 libexec/ld.elf_so/arch/i386/mdreloc.c      |  3 ++-
 libexec/ld.elf_so/arch/m68k/mdreloc.c      |  3 ++-
 libexec/ld.elf_so/arch/mips/mips_reloc.c   |  5 +++--
 libexec/ld.elf_so/arch/powerpc/ppc_reloc.c |  5 +++--
 libexec/ld.elf_so/arch/sh3/mdreloc.c       |  3 ++-
 libexec/ld.elf_so/arch/sparc/mdreloc.c     |  7 ++++---
 libexec/ld.elf_so/arch/sparc64/mdreloc.c   |  7 ++++---
 libexec/ld.elf_so/arch/vax/mdreloc.c       |  3 ++-
 libexec/ld.elf_so/arch/x86_64/mdreloc.c    |  7 +++++--
 libexec/ld.elf_so/reloc.c                  |  7 ++++---
 libexec/ld.elf_so/rtld.c                   |  8 ++++----
 libexec/ld.elf_so/rtld.h                   |  6 +++---
 15 files changed, 48 insertions(+), 33 deletions(-)

diffs (truncated from 333 to 300 lines):

diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/alpha/alpha_reloc.c
--- a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c        Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c        Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alpha_reloc.c,v 1.12 2002/09/06 13:20:31 mycroft Exp $ */
+/*     $NetBSD: alpha_reloc.c,v 1.13 2002/09/06 15:17:55 mycroft Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -109,8 +109,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
@@ -163,7 +164,7 @@
                        extern Elf_Addr _GOT_END_[];
 
                        /* This is the ...iffy hueristic. */
-                       if (!dodebug ||
+                       if (!self ||
                            (caddr_t)where < (caddr_t)_GLOBAL_OFFSET_TABLE_ ||
                            (caddr_t)where >= (caddr_t)_GOT_END_) {
                                *where += (Elf_Addr)obj->relocbase;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/arm/mdreloc.c
--- a/libexec/ld.elf_so/arch/arm/mdreloc.c      Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/arm/mdreloc.c      Fri Sep 06 15:17:53 2002 +0000
@@ -12,8 +12,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rel *rel;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/hppa/hppa_reloc.c
--- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c  Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c  Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hppa_reloc.c,v 1.10 2002/09/06 13:20:32 mycroft Exp $  */
+/*     $NetBSD: hppa_reloc.c,v 1.11 2002/09/06 15:17:56 mycroft Exp $  */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -319,8 +319,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
@@ -375,7 +376,7 @@
                                    rela->r_addend);
 
                                /* This is the ...iffy hueristic. */
-                               if (!dodebug ||
+                               if (!self ||
                                    (caddr_t)where < (caddr_t)_GLOBAL_OFFSET_TABLE_ ||
                                    (caddr_t)where >= (caddr_t)_GOT_END_) {
                                        if (*where != tmp)
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/i386/mdreloc.c
--- a/libexec/ld.elf_so/arch/i386/mdreloc.c     Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/i386/mdreloc.c     Fri Sep 06 15:17:53 2002 +0000
@@ -12,8 +12,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rel *rel;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/m68k/mdreloc.c
--- a/libexec/ld.elf_so/arch/m68k/mdreloc.c     Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/m68k/mdreloc.c     Fri Sep 06 15:17:53 2002 +0000
@@ -12,8 +12,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/mips/mips_reloc.c
--- a/libexec/ld.elf_so/arch/mips/mips_reloc.c  Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c  Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_reloc.c,v 1.15 2002/09/06 13:20:33 mycroft Exp $  */
+/*     $NetBSD: mips_reloc.c,v 1.16 2002/09/06 15:17:57 mycroft Exp $  */
 
 /*
  * Copyright 1997 Michael L. Hitch <mhitch%montana.edu@localhost>
@@ -134,8 +134,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rel *rel;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/powerpc/ppc_reloc.c
--- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c        Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c        Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ppc_reloc.c,v 1.20 2002/09/06 13:20:33 mycroft Exp $   */
+/*     $NetBSD: ppc_reloc.c,v 1.21 2002/09/06 15:17:57 mycroft Exp $   */
 
 /*-
  * Copyright (C) 1998  Tsubai Masanari
@@ -157,8 +157,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/sh3/mdreloc.c
--- a/libexec/ld.elf_so/arch/sh3/mdreloc.c      Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/sh3/mdreloc.c      Fri Sep 06 15:17:53 2002 +0000
@@ -12,8 +12,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/sparc/mdreloc.c
--- a/libexec/ld.elf_so/arch/sparc/mdreloc.c    Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/sparc/mdreloc.c    Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mdreloc.c,v 1.19 2002/09/06 03:12:07 mycroft Exp $     */
+/*     $NetBSD: mdreloc.c,v 1.20 2002/09/06 15:17:58 mycroft Exp $     */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -234,8 +234,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
@@ -275,7 +276,7 @@
                 * Handle relative relocs here, because we might not
                 * be able to access globals yet.
                 */
-               if (!dodebug && type == R_TYPE(RELATIVE)) {
+               if (self && type == R_TYPE(RELATIVE)) {
                        *where += (Elf_Addr)(obj->relocbase + value);
                        continue;
                }
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/sparc64/mdreloc.c
--- a/libexec/ld.elf_so/arch/sparc64/mdreloc.c  Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/sparc64/mdreloc.c  Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mdreloc.c,v 1.14 2002/09/06 03:12:08 mycroft Exp $     */
+/*     $NetBSD: mdreloc.c,v 1.15 2002/09/06 15:17:59 mycroft Exp $     */
 
 /*-
  * Copyright (c) 2000 Eduardo Horvath.
@@ -515,8 +515,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
@@ -557,7 +558,7 @@
                 * Handle relative relocs here, because we might not
                 * be able to access globals yet.
                 */
-               if (!dodebug && type == R_TYPE(RELATIVE)) {
+               if (self && type == R_TYPE(RELATIVE)) {
                        /* XXXX -- apparently we ignore the preexisting value */
                        *where = (Elf_Addr)(obj->relocbase + value);
                        continue;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/vax/mdreloc.c
--- a/libexec/ld.elf_so/arch/vax/mdreloc.c      Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/vax/mdreloc.c      Fri Sep 06 15:17:53 2002 +0000
@@ -12,8 +12,9 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(obj, dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
        const Obj_Entry *obj;
+       bool self;
        bool dodebug;
 {
        const Elf_Rela *rela;
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/arch/x86_64/mdreloc.c
--- a/libexec/ld.elf_so/arch/x86_64/mdreloc.c   Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/arch/x86_64/mdreloc.c   Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mdreloc.c,v 1.14 2002/09/06 13:20:35 mycroft Exp $     */
+/*     $NetBSD: mdreloc.c,v 1.15 2002/09/06 15:17:59 mycroft Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -89,7 +89,10 @@
 }
 
 int
-_rtld_relocate_nonplt_objects(const Obj_Entry *obj, bool dodebug)
+_rtld_relocate_nonplt_objects(obj, self, dodebug)
+       const Obj_Entry *obj;
+       bool self;
+       bool dodebug;
 {
        const Elf_Rela *rela;
 
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/reloc.c
--- a/libexec/ld.elf_so/reloc.c Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/reloc.c Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reloc.c,v 1.64 2002/09/06 13:20:30 mycroft Exp $        */
+/*     $NetBSD: reloc.c,v 1.65 2002/09/06 15:17:53 mycroft Exp $        */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -203,9 +203,10 @@
  * or -1 on failure.
  */
 int
-_rtld_relocate_objects(first, bind_now, dodebug)
+_rtld_relocate_objects(first, bind_now, self, dodebug)
        Obj_Entry *first;
        bool bind_now;
+       bool self;
        bool dodebug;
 {
        Obj_Entry *obj;
@@ -239,7 +240,7 @@
                                return -1;
                        }
                }
-               if (_rtld_relocate_nonplt_objects(obj, dodebug) < 0)
+               if (_rtld_relocate_nonplt_objects(obj, self, dodebug) < 0)
                        ok = 0;
                if (obj->textrel) {     /* Re-protected the text segment. */
                        if (mprotect(obj->mapbase, obj->textsize,
diff -r 85218813d459 -r 30c5b60eea0f libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c  Fri Sep 06 14:24:45 2002 +0000
+++ b/libexec/ld.elf_so/rtld.c  Fri Sep 06 15:17:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld.c,v 1.55 2002/09/06 13:27:48 junyoung Exp $        */
+/*     $NetBSD: rtld.c,v 1.56 2002/09/06 15:17:53 mycroft Exp $         */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -212,7 +212,7 @@
        assert(!objself.textrel);
 #endif
 
-       _rtld_relocate_objects(&objself, true, dodebug);
+       _rtld_relocate_objects(&objself, true, true, dodebug);
 
        /*
         * Now that we relocated ourselves, we can use globals.
@@ -505,7 +505,7 @@
                _rtld_objlist_add(&_rtld_list_main, obj);
 
        dbg(("relocating objects"));
-       if (_rtld_relocate_objects(_rtld_objmain, bind_now, true) == -1)



Home | Main Index | Thread Index | Old Index