From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1118) id 5CBC33858430; Sat, 1 Oct 2022 19:55:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CBC33858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664654108; bh=6YftZwhtWh+601TcyTvsEMnDoF8yd3MSzoYuAp145Kw=; h=From:To:Subject:Date:From; b=Te1kNIiE6AOtm8XVkeF9CrPQkYIbc2YyrfhRGuPGGLdJQVtIxY7j4VuUO+l6SejdC Z8+xf1G9Gb4bJyhvoUIe2Uh3D/rawJS6ucnoxlXU657Gj5MvPNuQ82a1iZ/71KXKoY YRXS42yd1CV1/7sOw1ySOhXoFViAB8NnahLQeiHo= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: John David Anglin To: glibc-cvs@sourceware.org Subject: [glibc/release/2.35/master] hppa: Fix initialization of dp register [BZ 29635] X-Act-Checkin: glibc X-Git-Author: John David Anglin X-Git-Refname: refs/heads/release/2.35/master X-Git-Oldrev: e36aeeaf0898524bb09afcdbcb39ea7db031bc97 X-Git-Newrev: 562e5b2821f5751e5c4304169572014c5a52e6d6 Message-Id: <20221001195508.5CBC33858430@sourceware.org> Date: Sat, 1 Oct 2022 19:55:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=562e5b2821f5751e5c4304169572014c5a52e6d6 commit 562e5b2821f5751e5c4304169572014c5a52e6d6 Author: John David Anglin Date: Sat Oct 1 19:49:25 2022 +0000 hppa: Fix initialization of dp register [BZ 29635] After upgrading glibc to Debian 2.35-1, gdb faulted on startup and dropped core in a function call in the main application. This was caused by not initializing the global dp register for the main application early enough. Restore the code to initialize dp in _dl_start_user. It was removed when code was added to initialize dp in elf_machine_runtime_setup. Signed-off-by: John David Anglin Diff: --- sysdeps/hppa/dl-machine.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index 7b647abfd7..1ba0aa372a 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -347,6 +347,16 @@ 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" \ @@ -426,6 +436,13 @@ asm ( \ direct loader invocation. Thus, argc and argv must be \ reloaded from from _dl_argc and _dl_argv. */ \ \ + /* Load main_map from _rtld_local and setup dp. */ \ +" addil LT'_rtld_local,%r19\n" \ +" ldw RT'_rtld_local(%r1),%r26\n" \ +" bl set_dp, %r2\n" \ +" ldw 0(%r26),%r26\n" \ +" copy %ret0,%r26\n" \ + \ /* Load argc from _dl_argc. */ \ " addil LT'_dl_argc,%r19\n" \ " ldw RT'_dl_argc(%r1),%r20\n" \ @@ -438,13 +455,10 @@ asm ( \ " ldw 0(%r20),%r24\n" \ " stw %r24,-44(%sp)\n" \ \ - /* Call _dl_init(main_map, argc, argv, envp). */ \ -" addil LT'_rtld_local,%r19\n" \ -" ldw RT'_rtld_local(%r1),%r26\n" \ -" ldw 0(%r26),%r26\n" \ - \ /* envp = argv + argc + 1 */ \ " sh2add %r25,%r24,%r23\n" \ + \ + /* Call _dl_init(main_map, argc, argv, envp). */ \ " bl _dl_init,%r2\n" \ " ldo 4(%r23),%r23\n" /* delay slot */ \ \