[RFA] machoread.c: avoid a crash on OSO without symbols.
Commit Message
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(+)
@@ -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
@@ -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)