From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Avoid crash with absolute symbol
Date: Tue, 20 Jun 2023 15:21:03 -0600 [thread overview]
Message-ID: <20230620212103.2185862-1-tom@tromey.com> (raw)
A user supplied an executable and a remote logfile that could be used
to crash gdb. The problem is that the BFD section for a particular
symbol was null, because the section was not marked "allocated".
Digging deeper, the problem was that elfread.c dropped the section for
absolute symbols. This patch fixes the crash.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30431
---
gdb/elfread.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 799e3b914f8..7697106e9b6 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -216,7 +216,8 @@ record_minimal_symbol (minimal_symbol_reader &reader,
ELF is malformed then this might not be the case. In that case don't
create an msymbol that references an uninitialised section object. */
int section_index = 0;
- if ((bfd_section_flags (bfd_section) & SEC_ALLOC) == SEC_ALLOC)
+ if ((bfd_section_flags (bfd_section) & SEC_ALLOC) == SEC_ALLOC
+ || bfd_section == bfd_abs_section_ptr)
section_index = gdb_bfd_section_index (objfile->obfd.get (), bfd_section);
struct minimal_symbol *result
--
2.39.2
next reply other threads:[~2023-06-20 21:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 21:21 Tom Tromey [this message]
2023-07-10 17:01 ` Tom Tromey
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=20230620212103.2185862-1-tom@tromey.com \
--to=tom@tromey.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).