Add target_ops argument to to_pid_to_exec_file
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 89ed34cb417b7dc5f7d2990b7fd98170d036e387..06d2119072640d715fd311529accf996bd930f24 100644 (file)
@@ -867,6 +867,12 @@ read_symbols (struct objfile *objfile, int add_flags)
 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.  */
 
@@ -874,8 +880,8 @@ init_entry_point_info (struct objfile *objfile)
     {
       /* Executable file -- record its entry point so we'll recognize
          the startup file because it contains the entry point.  */
-      objfile->ei.entry_point = bfd_get_start_address (objfile->obfd);
-      objfile->ei.entry_point_p = 1;
+      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)
@@ -883,18 +889,20 @@ init_entry_point_info (struct objfile *objfile)
       /* 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.  */
-      objfile->ei.entry_point = bfd_get_start_address (objfile->obfd);
-      objfile->ei.entry_point_p = 1;
+      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.  */
-      objfile->ei.entry_point_p = 0;
+      ei->entry_point_p = 0;
     }
 
-  if (objfile->ei.entry_point_p)
+  if (ei->entry_point_p)
     {
-      CORE_ADDR entry_point =  objfile->ei.entry_point;
+      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.  */
@@ -905,8 +913,27 @@ init_entry_point_info (struct objfile *objfile)
 
       /* Remove any ISA markers, so that this matches entries in the
         symbol table.  */
-      objfile->ei.entry_point
+      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);
     }
 }
 
@@ -1627,11 +1654,9 @@ symbol_file_command (char *args, int from_tty)
 void
 set_initial_language (void)
 {
-  enum language lang = language_unknown;
+  enum language lang = main_language ();
 
-  if (language_of_main != language_unknown)
-    lang = language_of_main;
-  else
+  if (lang == language_unknown)
     {
       char *name = main_name ();
       struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
@@ -3843,16 +3868,19 @@ symfile_free_objfile (struct objfile *objfile)
    See quick_symbol_functions.expand_symtabs_matching for details.  */
 
 void
-expand_partial_symbol_names (expand_symtabs_symbol_matcher_ftype *fun,
-                            void *data)
+expand_symtabs_matching (expand_symtabs_file_matcher_ftype *file_matcher,
+                        expand_symtabs_symbol_matcher_ftype *symbol_matcher,
+                        enum search_domain kind,
+                        void *data)
 {
   struct objfile *objfile;
 
   ALL_OBJFILES (objfile)
   {
     if (objfile->sf)
-      objfile->sf->qf->expand_symtabs_matching (objfile, NULL, fun,
-                                               ALL_DOMAIN, data);
+      objfile->sf->qf->expand_symtabs_matching (objfile, file_matcher,
+                                               symbol_matcher, kind,
+                                               data);
   }
 }
 
@@ -3861,8 +3889,8 @@ expand_partial_symbol_names (expand_symtabs_symbol_matcher_ftype *fun,
    See quick_symbol_functions.map_symbol_filenames for details.  */
 
 void
-map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
-                             int need_fullname)
+map_symbol_filenames (symbol_filename_ftype *fun, void *data,
+                     int need_fullname)
 {
   struct objfile *objfile;
 
This page took 0.039397 seconds and 4 git commands to generate.