aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 13a8c55..03a49a9 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1113,6 +1113,14 @@ update_section_map (struct program_space *pspace,
if (insert_section_p (objfile->obfd, s->the_bfd_section))
alloc_size += 1;
+ /* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
+ if (alloc_size == 0)
+ {
+ *pmap = NULL;
+ *pmap_size = 0;
+ return;
+ }
+
map = xmalloc (alloc_size * sizeof (*map));
i = 0;
@@ -1175,6 +1183,14 @@ find_pc_section (CORE_ADDR pc)
pspace_info->objfiles_changed_p = 0;
}
+ /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
+ bsearch be non-NULL. */
+ if (pspace_info->sections == NULL)
+ {
+ gdb_assert (pspace_info->num_sections == 0);
+ return NULL;
+ }
+
sp = (struct obj_section **) bsearch (&pc,
pspace_info->sections,
pspace_info->num_sections,