From: "Lluís Batlle i Rossell" <viric@viric.name>
To: gdb-patches@sourceware.org
Subject: [PATCH] Trust DT_DEBUG in AUXV better than in ELF
Date: Sat, 9 Nov 2024 15:05:41 +0100 [thread overview]
Message-ID: <k7pa62frbhyzjxuneamsbjr6ots7atmvl2d3qs7o62fu3jow2v@fnfqmbhegolg> (raw)
[-- Attachment #1: Type: text/plain, Size: 162 bytes --]
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.
[-- Attachment #2: 0001-Trust-DT_DEBUG-in-AUXV-better-than-in-ELF.patch --]
[-- Type: text/plain, Size: 1194 bytes --]
From 382e0285e8f8b42a9e72c5267f726cf574b2d299 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= <viric@viric.name>
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
reply other threads:[~2024-11-09 14:06 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=k7pa62frbhyzjxuneamsbjr6ots7atmvl2d3qs7o62fu3jow2v@fnfqmbhegolg \
--to=viric@viric.name \
--cc=gdb-patches@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