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/hppa Set DP early so that any binary ...



details:   https://anonhg.NetBSD.org/src/rev/c3c10656e489
branches:  trunk
changeset: 366563:c3c10656e489
user:      skrll <skrll%NetBSD.org@localhost>
date:      Mon May 30 17:06:34 2022 +0000

description:
Set DP early so that any binary functions that override others get the
right value if they're called before _start.  This is true of bash where
it provides its own getenv.

Part of port-hppa/56118: sporadic app crashes in HPPA -current

diffstat:

 libexec/ld.elf_so/arch/hppa/hppa_reloc.c |  15 +++++++++++++--
 libexec/ld.elf_so/arch/hppa/rtld_start.S |   8 +++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diffs (62 lines):

diff -r 5b9532738b7e -r c3c10656e489 libexec/ld.elf_so/arch/hppa/hppa_reloc.c
--- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c  Mon May 30 15:22:44 2022 +0000
+++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c  Mon May 30 17:06:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hppa_reloc.c,v 1.48 2021/12/04 14:39:08 skrll Exp $    */
+/*     $NetBSD: hppa_reloc.c,v 1.49 2022/05/30 17:06:34 skrll Exp $    */
 
 /*-
  * Copyright (c) 2002, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: hppa_reloc.c,v 1.48 2021/12/04 14:39:08 skrll Exp $");
+__RCSID("$NetBSD: hppa_reloc.c,v 1.49 2022/05/30 17:06:34 skrll Exp $");
 #endif /* not lint */
 
 #include <stdlib.h>
@@ -52,6 +52,7 @@
 caddr_t _rtld_bind(const Obj_Entry *, const Elf_Addr);
 void _rtld_bind_start(void);
 void __rtld_setup_hppa_pltgot(const Obj_Entry *, Elf_Addr *);
+void _rtld_set_dp(Elf_Addr *);
 
 /*
  * It is possible for the compiler to emit relocations for unaligned data.
@@ -417,6 +418,16 @@
        const Obj_Entry *defobj = NULL;
        unsigned long last_symnum = ULONG_MAX;
 
+       /*
+        * This will be done by the crt0 code, but make sure it's set
+        * early so that symbols overridden by the non-pic binary
+        * get the right DP value.
+        */
+       if (obj->mainprog) {
+               hdbg(("setting DP to %p", obj->pltgot));
+               _rtld_set_dp(obj->pltgot);
+       }
+
        for (rela = obj->rela; rela < obj->relalim; rela++) {
                Elf_Addr        *where;
                Elf_Addr         tmp;
diff -r 5b9532738b7e -r c3c10656e489 libexec/ld.elf_so/arch/hppa/rtld_start.S
--- a/libexec/ld.elf_so/arch/hppa/rtld_start.S  Mon May 30 15:22:44 2022 +0000
+++ b/libexec/ld.elf_so/arch/hppa/rtld_start.S  Mon May 30 17:06:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld_start.S,v 1.13 2020/05/10 06:42:38 skrll Exp $    */
+/*     $NetBSD: rtld_start.S,v 1.14 2022/05/30 17:06:34 skrll Exp $    */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -231,3 +231,9 @@
        bv      %r0(%r21)
        nop
 EXIT(_rtld_bind_start)
+
+
+LEAF_ENTRY_NOPROFILE(_rtld_set_dp)
+       bv      %r0(%rp)
+        copy   %arg0, %dp
+EXIT(_rtld_set_dp)



Home | Main Index | Thread Index | Old Index