public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: John David Anglin <danglin@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.35/master] Fix elf/tst-audit2 on hppa
Date: Thu,  3 Mar 2022 21:18:54 +0000 (GMT)	[thread overview]
Message-ID: <20220303211854.BE759385840B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1f770811785e6c79db995b0390d1ef4e67e87d44

commit 1f770811785e6c79db995b0390d1ef4e67e87d44
Author: John David Anglin <danglin@gcc.gnu.org>
Date:   Mon Feb 14 15:14:49 2022 +0000

    Fix elf/tst-audit2 on hppa
    
    The test elf/tst-audit2 fails on hppa with a segmentation fault in the
    long branch stub used to call malloc from calloc.  This occurs because
    the test is not a PIC executable and calloc is called from the dynamic
    linker before the dp register is initialized in _dl_start_user.
    
    The fix is to move the dp register initialization into
    elf_machine_runtime_setup.  Since the address of $global$ can't be
    loaded directly, we continue to use the DT_PLTGOT value from the
    the main_map to initialize dp.
    
    (cherry picked from commit 2e20cd63c96555d650c525ad5633475e8f11bed4)

Diff:
---
 sysdeps/hppa/dl-machine.h | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index da4d57d2e4..7b7a697cbb 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -176,6 +176,15 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
     Elf32_Addr i[2];
   } sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
 
+  /* Initialize dp register for main executable.  */
+  if (l->l_main_map)
+    {
+      register Elf32_Addr dp asm ("%r27");
+
+      dp = D_PTR (l, l_info[DT_PLTGOT]);
+      asm volatile ("" : : "r" (dp));
+    }
+
   /* If we don't have a PLT we can just skip all this... */
   if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0))
     return lazy;
@@ -338,16 +347,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
    its return value is the user program's entry point.  */
 
 #define RTLD_START \
-/* Set up dp for any non-PIC lib constructors that may be called.  */	\
-static struct link_map * __attribute__((used))				\
-set_dp (struct link_map *map)						\
-{									\
-  register Elf32_Addr dp asm ("%r27");					\
-  dp = D_PTR (map, l_info[DT_PLTGOT]);					\
-  asm volatile ("" : : "r" (dp));					\
-  return map;								\
-}									\
-									\
 asm (									\
 "	.text\n"							\
 "	.globl _start\n"						\
@@ -447,14 +446,11 @@ asm (									\
 "	stw	%r24,-44(%sp)\n"					\
 									\
 ".Lnofix:\n"								\
+	/* Call _dl_init(main_map, argc, argv, envp). */		\
 "	addil	LT'_rtld_local,%r19\n"					\
 "	ldw	RT'_rtld_local(%r1),%r26\n"				\
-"	bl	set_dp, %r2\n"						\
 "	ldw	0(%r26),%r26\n"						\
 									\
-	/* Call _dl_init(_dl_loaded, argc, argv, envp). */		\
-"	copy	%r28,%r26\n"						\
-									\
 	/* envp = argv + argc + 1 */					\
 "	sh2add	%r25,%r24,%r23\n"					\
 "	bl	_dl_init,%r2\n"						\


                 reply	other threads:[~2022-03-03 21:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220303211854.BE759385840B@sourceware.org \
    --to=danglin@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).