+/* This is a convenience function to call sym_read for OBJFILE and
+ possibly force the partial symbols to be read. */
+
+static void
+read_symbols (struct objfile *objfile, int add_flags)
+{
+ (*objfile->sf->sym_read) (objfile, add_flags);
+ objfile->per_bfd->minsyms_read = 1;
+
+ /* find_separate_debug_file_in_section should be called only if there is
+ single binary with no existing separate debug info file. */
+ if (!objfile_has_partial_symbols (objfile)
+ && objfile->separate_debug_objfile == NULL
+ && objfile->separate_debug_objfile_backlink == NULL)
+ {
+ bfd *abfd = find_separate_debug_file_in_section (objfile);
+ struct cleanup *cleanup = make_cleanup_bfd_unref (abfd);
+
+ if (abfd != NULL)
+ {
+ /* find_separate_debug_file_in_section uses the same filename for the
+ virtual section-as-bfd like the bfd filename containing the
+ section. Therefore use also non-canonical name form for the same
+ file containing the section. */
+ symbol_file_add_separate (abfd, objfile->original_name, add_flags,
+ objfile);
+ }
+
+ do_cleanups (cleanup);
+ }
+ if ((add_flags & SYMFILE_NO_READ) == 0)
+ require_partial_symbols (objfile, 0);
+}
+
+/* Initialize entry point information for this objfile. */
+
+static void
+init_entry_point_info (struct objfile *objfile)
+{
+ struct entry_info *ei = &objfile->per_bfd->ei;
+
+ if (ei->initialized)
+ return;
+ ei->initialized = 1;
+
+ /* Save startup file's range of PC addresses to help blockframe.c
+ decide where the bottom of the stack is. */
+
+ if (bfd_get_file_flags (objfile->obfd) & EXEC_P)
+ {
+ /* Executable file -- record its entry point so we'll recognize
+ the startup file because it contains the entry point. */
+ ei->entry_point = bfd_get_start_address (objfile->obfd);
+ ei->entry_point_p = 1;
+ }
+ else if (bfd_get_file_flags (objfile->obfd) & DYNAMIC
+ && bfd_get_start_address (objfile->obfd) != 0)
+ {
+ /* Some shared libraries may have entry points set and be
+ runnable. There's no clear way to indicate this, so just check
+ for values other than zero. */
+ ei->entry_point = bfd_get_start_address (objfile->obfd);
+ ei->entry_point_p = 1;
+ }
+ else
+ {
+ /* Examination of non-executable.o files. Short-circuit this stuff. */
+ ei->entry_point_p = 0;
+ }
+
+ if (ei->entry_point_p)
+ {
+ struct obj_section *osect;
+ CORE_ADDR entry_point = ei->entry_point;
+ int found;
+
+ /* Make certain that the address points at real code, and not a
+ function descriptor. */
+ entry_point
+ = gdbarch_convert_from_func_ptr_addr (get_objfile_arch (objfile),
+ entry_point,
+ ¤t_target);
+
+ /* Remove any ISA markers, so that this matches entries in the
+ symbol table. */
+ ei->entry_point
+ = gdbarch_addr_bits_remove (get_objfile_arch (objfile), entry_point);
+
+ found = 0;
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ struct bfd_section *sect = osect->the_bfd_section;
+
+ if (entry_point >= bfd_get_section_vma (objfile->obfd, sect)
+ && entry_point < (bfd_get_section_vma (objfile->obfd, sect)
+ + bfd_get_section_size (sect)))
+ {
+ ei->the_bfd_section_index
+ = gdb_bfd_section_index (objfile->obfd, sect);
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ ei->the_bfd_section_index = SECT_OFF_TEXT (objfile);
+ }
+}
+