From patchwork Sat Oct 1 20:00:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 58262 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 03CA03858298 for ; Sat, 1 Oct 2022 20:01:21 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dellerweb.de (unknown [IPv6:2a02:c207:3003:236::1]) by sourceware.org (Postfix) with ESMTPS id 2061E38582B0 for ; Sat, 1 Oct 2022 20:00:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2061E38582B0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bell.net Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=bell.net Received: from mx3210.localdomain (bras-base-otwaon0925w-grc-09-174-95-58-43.dsl.bell.ca [174.95.58.43]) by dellerweb.de (Postfix) with ESMTPSA id 1AD09160002B; Sat, 1 Oct 2022 22:00:54 +0200 (CEST) Received: by mx3210.localdomain (Postfix, from userid 1000) id 3085222011B; Sat, 1 Oct 2022 20:00:52 +0000 (UTC) Date: Sat, 1 Oct 2022 20:00:51 +0000 From: John David Anglin To: libc-alpha@sourceware.org Subject: [committed] hppa: Fix initialization of dp register [BZ 29635] Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, MAY_BE_FORGED, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Helge Deller Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index c865713be1..1d51948566 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 */ \ \