From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wOrwGE9sL2cENisAWB0awg (envelope-from ) for ; Sat, 09 Nov 2024 09:06:07 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=viric.name header.i=@viric.name header.a=rsa-sha256 header.s=dkim1 header.b=EbixEAJ8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 49BEF1E61E; Sat, 9 Nov 2024 09:06:07 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1A4FC1E61C for ; Sat, 9 Nov 2024 09:06:04 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AB933858CDA for ; Sat, 9 Nov 2024 14:06:03 +0000 (GMT) Received: from mail.viric.name (mail.viric.name [37.18.133.75]) by sourceware.org (Postfix) with ESMTPS id 383AD3858D37 for ; Sat, 9 Nov 2024 14:05:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 383AD3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=viric.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=viric.name ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 383AD3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=37.18.133.75 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731161145; cv=none; b=C7DUBc8PNLGOZS+ZY/19AD6nRmJS20jQnUTZxKodRMtPBWfDUbXiUw7Y5KAsgE7S16pDRPJcnspKeCruX7+Qhkcoii1WXIQJW4/MShZE87qazNnAEYv8u5WXNwyAXPGfxICEYN5Sp2yarXqVpJVoUGkD8uONPAG68lGiEyePvC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731161145; c=relaxed/simple; bh=B6dmKYvrbcYNJI2jVb66t0JF5VYAJny7aTwQLsvwHAI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=xpKumXzwNigDdgLjnh/zsO9bFRWD70Y08foZL/dP+oqWsedVgflOiKIhAMt+2TnmAwDkPON3phGgTCeCwP/4se6UZ4CIgSy/Kybz6gcmMZ7trRTbn59CDM4SAFYcSwoQLNEpeCtk1/heMkCO/QtGJSd0ZHZ0kr6TDxFY8g2odk0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail.viric.name (Postfix, from userid 1000) id 080EE1408A06; Sat, 09 Nov 2024 15:05:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=viric.name; s=dkim1; t=1731161142; bh=B6dmKYvrbcYNJI2jVb66t0JF5VYAJny7aTwQLsvwHAI=; h=Date:From:To:Subject; b=EbixEAJ8ZEFk024xCshBIwbQ5TcYYGpNQrmmTRRBZulNyG7/xdZWxAKd0GKJDqYxA zvNZOHWjV9njYn0hZdvdKNQCeToBJfDziLSt+W4B4DqaF1YNBsVC/olS/GJVnThKIN daH4SCi4dw1FTmOVPHYGRaqiwjYP8qPQ16eWCIZ8= Date: Sat, 9 Nov 2024 15:05:41 +0100 From: =?utf-8?B?TGx1w61z?= Batlle i Rossell To: gdb-patches@sourceware.org Subject: [PATCH] Trust DT_DEBUG in AUXV better than in ELF Message-ID: X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="6lrkqjywzsnz66gr" Content-Disposition: inline X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org --6lrkqjywzsnz66gr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch helped me debug core-dumps generated from executing a post-processed ELF. I don't know if changing the DT_DEBUG check order (AUXV, ELF) harms anyone. --6lrkqjywzsnz66gr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Trust-DT_DEBUG-in-AUXV-better-than-in-ELF.patch" >From 382e0285e8f8b42a9e72c5267f726cf574b2d299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 9 Nov 2024 15:01:53 +0100 Subject: [PATCH] Trust DT_DEBUG in AUXV better than in ELF In cases of core dump, sometimes the ELF can be recreated and we should rather trust what is in the core dump than the ELF. --- gdb/solib-svr4.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 8378ecaff40..8f4450323a5 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -742,10 +742,11 @@ elf_locate_base (void) return extract_typed_address (pbuf, ptr_type); } - /* Find DT_DEBUG. */ - if (gdb_bfd_scan_elf_dyntag (DT_DEBUG, current_program_space->exec_bfd (), - &dyn_ptr, NULL) - || scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL)) + /* Find DT_DEBUG. + Trust better the DT_DEBUG in AUXV */ + if (scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL) || + gdb_bfd_scan_elf_dyntag (DT_DEBUG, current_program_space->exec_bfd (), + &dyn_ptr, NULL)) return dyn_ptr; /* This may be a static executable. Look for the symbol -- 2.44.1 --6lrkqjywzsnz66gr--