NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

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




I've also built bash from prksrc/shells/bash, and this crashes at startup. Don't know if this is related, but for completeness:

[snip]

The bash problem is kinda interesting. bash provides its own getenv and
this is being used by early initialization code in libc / jemalloc when
it does getenv("MALLOC_CONF") before _start has been called in the main
program. _start sets the dp register which needs to contain the GOT of
the main program...

This diff allows bash to start.

I'm still thinking about if it's the right thing to do.

Nick

Index: arch/hppa/hppa_reloc.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c,v
retrieving revision 1.47
diff -u -p -r1.47 hppa_reloc.c
--- arch/hppa/hppa_reloc.c	16 May 2020 16:43:00 -0000	1.47
+++ arch/hppa/hppa_reloc.c	16 Jul 2021 06:56:51 -0000
@@ -52,6 +52,7 @@ __RCSID("$NetBSD: hppa_reloc.c,v 1.47 20
 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.
@@ -381,6 +382,12 @@ _rtld_setup_pltgot(const Obj_Entry *obj)
 {
 	Elf_Word *got = obj->pltgot;
 
+
+	if (obj->mainprog) {
+		dbg(("setting DP to %p", obj->pltgot);
+		_rtld_set_dp(obj->pltgot);
+	}
+
 	assert(got[-2] == PLT_STUB_MAGIC1);
 	assert(got[-1] == PLT_STUB_MAGIC2);
 
Index: arch/hppa/rtld_start.S
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/hppa/rtld_start.S,v
retrieving revision 1.13
diff -u -p -r1.13 rtld_start.S
--- arch/hppa/rtld_start.S	10 May 2020 06:42:38 -0000	1.13
+++ arch/hppa/rtld_start.S	16 Jul 2021 06:56:51 -0000
@@ -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)


Home | Main Index | Thread Index | Old Index