+/* 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);
+ }
+}
+