sim: don't rely on inferior_ptid in gdbsim_target::wait
[deliverable/binutils-gdb.git] / gdb / elfread.c
index 618e4cd566cad41d36647fd95365bc6922c6ea46..453bca527e9b219aadab714c3faeff8cdcb121d9 100644 (file)
@@ -210,11 +210,16 @@ record_minimal_symbol (minimal_symbol_reader &reader,
       || ms_type == mst_text_gnu_ifunc)
     address = gdbarch_addr_bits_remove (gdbarch, address);
 
+  /* We only setup section information for allocatable sections.  Usually
+     we'd only expect to find msymbols for allocatable sections, but if the
+     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)
+    section_index = gdb_bfd_section_index (objfile->obfd, bfd_section);
+
   struct minimal_symbol *result
-    = reader.record_full (name, copy_name, address,
-                         ms_type,
-                         gdb_bfd_section_index (objfile->obfd,
-                                                bfd_section));
+    = reader.record_full (name, copy_name, address, ms_type, section_index);
   if ((objfile->flags & OBJF_MAINLINE) == 0
       && (ms_type == mst_data || ms_type == mst_bss))
     result->maybe_copied = 1;
@@ -1469,8 +1474,9 @@ static const struct gnu_ifunc_fns elf_gnu_ifunc_fns =
   elf_gnu_ifunc_resolver_return_stop
 };
 
+void _initialize_elfread ();
 void
-_initialize_elfread (void)
+_initialize_elfread ()
 {
   add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
 
This page took 0.02447 seconds and 4 git commands to generate.