public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Avoid crash with absolute symbol
@ 2023-06-20 21:21 Tom Tromey
  2023-07-10 17:01 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-06-20 21:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Avoid crash with absolute symbol
  2023-06-20 21:21 [PATCH] Avoid crash with absolute symbol Tom Tromey
@ 2023-07-10 17:01 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-07-10 17:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> A user supplied an executable and a remote logfile that could be used
Tom> to crash gdb.  The problem is that the BFD section for a particular
Tom> symbol was null, because the section was not marked "allocated".
Tom> Digging deeper, the problem was that elfread.c dropped the section for
Tom> absolute symbols.  This patch fixes the crash.

Tom> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30431

I'm checking this in.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-10 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 21:21 [PATCH] Avoid crash with absolute symbol Tom Tromey
2023-07-10 17:01 ` Tom Tromey

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).