This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] machoread.c: avoid a crash on OSO without symbols.
- From: Xavier Roirand <roirand at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: brobecker at adacore dot com, Xavier Roirand <roirand at adacore dot com>, tgingold at free dot fr
- Date: Tue, 27 Feb 2018 11:25:38 +0100
- Subject: [RFA] machoread.c: avoid a crash on OSO without symbols.
- Authentication-results: sourceware.org; auth=none
gdb/ChangeLog (Tristan Gingold <gingold@adacore.com>)
* machoread.c (macho_add_oso_symfile): Handle weird case
of OSO without symbols.
---
gdb/ChangeLog | 6 ++++++
gdb/machoread.c | 5 +++++
2 files changed, 11 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b9a9bcd..83b5073 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-27 Tristan Gingold <gingold@adacore.com>
+
+ Pushed by Xavier Roirand <roirand@adacore.com>
+ * machoread.c (macho_add_oso_symfile): Handle weird case
+ of OSO without symbols.
+
2018-02-26 Maciej W. Rozycki <macro@mips.com>
* mips-tdep.c (mips_gdbarch_init): Don't use a 32-bit BFD
diff --git a/gdb/machoread.c b/gdb/machoread.c
index b270675..b00ef13 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -579,6 +579,11 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
{
struct macho_sym_hash_entry *ent;
+ /* Nothing to do if there is no symbol (and avoid a crash
+ while creating an empty hash table). */
+ if (oso->nbr_syms == 0)
+ continue;
+
ent = (struct macho_sym_hash_entry *)
bfd_hash_lookup (&table, sym->name, FALSE, FALSE);
if (ent != NULL)
--
2.7.4