summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2022-06-10 17:39:10 +0000
committermartin <martin@NetBSD.org>2022-06-10 17:39:10 +0000
commit6275566403058b247fadd1a5a1adbb2abf08f362 (patch)
treef90356d83092e0e816011e5de0cb0e416d40fa2a
parentdbbb7aac217b4adf6399815840ad88ab75265f62 (diff)
Pull up following revision(s) (requested by skrll in ticket #1469):
libexec/ld.elf_so/arch/hppa/hppa_reloc.c: revision 1.49 libexec/ld.elf_so/arch/hppa/rtld_start.S: revision 1.14 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
-rw-r--r--libexec/ld.elf_so/arch/hppa/hppa_reloc.c15
-rw-r--r--libexec/ld.elf_so/arch/hppa/rtld_start.S8
2 files changed, 20 insertions, 3 deletions
diff --git a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
index 5669b976300..e0ce1c089ab 100644
--- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
+++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hppa_reloc.c,v 1.45 2017/08/10 19:03:26 joerg Exp $ */
+/* $NetBSD: hppa_reloc.c,v 1.45.6.1 2022/06/10 17:39:10 martin 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.45 2017/08/10 19:03:26 joerg Exp $");
+__RCSID("$NetBSD: hppa_reloc.c,v 1.45.6.1 2022/06/10 17:39:10 martin Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -52,6 +52,7 @@ __RCSID("$NetBSD: hppa_reloc.c,v 1.45 2017/08/10 19:03:26 joerg Exp $");
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 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
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 --git a/libexec/ld.elf_so/arch/hppa/rtld_start.S b/libexec/ld.elf_so/arch/hppa/rtld_start.S
index 230fc427183..47659fce54d 100644
--- a/libexec/ld.elf_so/arch/hppa/rtld_start.S
+++ b/libexec/ld.elf_so/arch/hppa/rtld_start.S
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld_start.S,v 1.12 2012/01/06 10:38:57 skrll Exp $ */
+/* $NetBSD: rtld_start.S,v 1.12.42.1 2022/06/10 17:39:10 martin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -231,3 +231,9 @@ ENTRY(_rtld_bind_start,HPPA_FRAME_SIZE)
bv %r0(%r21)
nop
EXIT(_rtld_bind_start)
+
+
+LEAF_ENTRY_NOPROFILE(_rtld_set_dp)
+ bv %r0(%rp)
+ copy %arg0, %dp
+EXIT(_rtld_set_dp)