*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / xcoffread.c
index fcabddb658b44cdf4e8b9a39499ae2e10dbdfe7f..af93a4345b67f13584f3a14a7a63fe8a2a2e72f9 100644 (file)
@@ -162,6 +162,7 @@ static const struct dwarf2_debug_sections dwarf2_xcoff_names = {
   { ".dwstr", NULL },
   { ".dwrnges", NULL },
   { NULL, NULL }, /* debug_types */
+  { NULL, NULL }, /* debug_addr */
   { ".dwframe", NULL },
   { NULL, NULL }, /* eh_frame */
   { NULL, NULL }, /* gdb_index */
@@ -272,36 +273,53 @@ find_targ_sec (bfd *abfd, asection *sect, void *obj)
     }
 }
 
-/* Return the section number (SECT_OFF_*) that CS points to.  */
-static int
-secnum_to_section (int secnum, struct objfile *objfile)
-{
-  int off = SECT_OFF_TEXT (objfile);
+/* Search all BFD sections for the section whose target_index is
+   equal to N_SCNUM.  Set *BFD_SECT to that section.  The section's
+   associated index in the objfile's section_offset table is also
+   stored in *SECNUM.
 
-  asection *sect = NULL;
+   If no match is found, *BFD_SECT is set to NULL, and *SECNUM
+   is set to the text section's number.  */
+
+static void
+xcoff_secnum_to_sections (int n_scnum, struct objfile *objfile,
+                         asection **bfd_sect, int *secnum)
+{
   struct find_targ_sec_arg args;
-  args.targ_index = secnum;
-  args.resultp = &off;
-  args.bfd_sect = §
+
+  args.targ_index = n_scnum;
+  args.resultp = secnum;
+  args.bfd_sect = bfd_sect;
   args.objfile = objfile;
+
+  *bfd_sect = NULL;
+  *secnum = SECT_OFF_TEXT (objfile);
+
   bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
-  return off;
 }
 
-/* Return the BFD section that CS points to.  */
+/* Return the section number (SECT_OFF_*) that N_SCNUM points to.  */
+
+static int
+secnum_to_section (int n_scnum, struct objfile *objfile)
+{
+  int secnum;
+  asection *ignored;
+
+  xcoff_secnum_to_sections (n_scnum, objfile, &ignored, &secnum);
+  return secnum;
+}
+
+/* Return the BFD section that N_SCNUM points to.  */
+
 static asection *
-secnum_to_bfd_section (int secnum, struct objfile *objfile)
+secnum_to_bfd_section (int n_scnum, struct objfile *objfile)
 {
-  int off = SECT_OFF_TEXT (objfile);
+  int ignored;
+  asection *bfd_sect;
 
-  asection *sect = NULL;
-  struct find_targ_sec_arg args;
-  args.targ_index = secnum;
-  args.resultp = &off;
-  args.bfd_sect = §
-  args.objfile = objfile;
-  bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
-  return sect;
+  xcoff_secnum_to_sections (n_scnum, objfile, &bfd_sect, &ignored);
+  return bfd_sect;
 }
 \f
 /* add a given stab string into given stab vector.  */
@@ -877,21 +895,33 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
    This function can read past the end of the symbol table
    (into the string table) but this does no harm.  */
 
-/* Reading symbol table has to be fast! Keep the followings as macros, rather
-   than functions.  */
-
-#define        RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \
-{                                              \
-  const char *namestr;                         \
-                                               \
-  namestr = (NAME);                            \
-  if (namestr[0] == '.') ++namestr;            \
-  prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE),     \
-                                      (SECTION), (asection *)NULL, \
-                                      (OBJFILE));                  \
-  misc_func_recorded = 1;                      \
-}
+/* Create a new minimal symbol (using prim_record_minimal_symbol_and_info).
+
+   Arguments are:
 
+   NAME - the symbol's name (but if NAME starts with a period, that
+   leading period is discarded).
+   ADDRESS - the symbol's address.
+   MS_TYPE - the symbol's type.
+   N_SCNUM - the symbol's XCOFF section number.
+   OBJFILE - the objfile associated with the minimal symbol.  */
+
+static void
+record_minimal_symbol (const char *name, CORE_ADDR address,
+                      enum minimal_symbol_type ms_type,
+                      int n_scnum,
+                      struct objfile *objfile)
+{
+  int secnum;
+  asection *bfd_sect;
+
+  if (name[0] == '.')
+    ++name;
+
+  xcoff_secnum_to_sections (n_scnum, objfile, &bfd_sect, &secnum);
+  prim_record_minimal_symbol_and_info (name, address, ms_type,
+                                      secnum, bfd_sect, objfile);
+}
 
 /* xcoff has static blocks marked in `.bs', `.es' pairs.  They cannot be
    nested.  At any given time, a symbol can only be in one static block.
@@ -2277,10 +2307,10 @@ scan_xcoff_symtab (struct objfile *objfile)
 
                        if (!misc_func_recorded)
                          {
-                           RECORD_MINIMAL_SYMBOL
+                           record_minimal_symbol
                              (last_csect_name, last_csect_val,
-                              mst_text, last_csect_sec,
-                              objfile);
+                              mst_text, last_csect_sec, objfile);
+                           misc_func_recorded = 1;
                          }
 
                        if (pst != NULL)
@@ -2312,8 +2342,7 @@ scan_xcoff_symtab (struct objfile *objfile)
                      {
                        last_csect_name = namestring;
                        last_csect_val = symbol.n_value;
-                       last_csect_sec =
-                         secnum_to_section (symbol.n_scnum, objfile);
+                       last_csect_sec = symbol.n_scnum;
                      }
                    if (pst != NULL)
                      {
@@ -2337,7 +2366,8 @@ scan_xcoff_symtab (struct objfile *objfile)
                        (namestring, symbol.n_value,
                         sclass == C_HIDEXT ? mst_file_data : mst_data,
                         secnum_to_section (symbol.n_scnum, objfile),
-                        NULL, objfile);
+                        secnum_to_bfd_section (symbol.n_scnum, objfile),
+                        objfile);
                    break;
 
                  case XMC_TC0:
@@ -2371,11 +2401,13 @@ scan_xcoff_symtab (struct objfile *objfile)
                    if (first_fun_line_offset == 0 && symbol.n_numaux > 1)
                      first_fun_line_offset =
                        main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
-                   RECORD_MINIMAL_SYMBOL
-                     (namestring, symbol.n_value,
-                      sclass == C_HIDEXT ? mst_file_text : mst_text,
-                      secnum_to_section (symbol.n_scnum, objfile),
-                      objfile);
+                     {
+                       record_minimal_symbol
+                         (namestring, symbol.n_value,
+                          sclass == C_HIDEXT ? mst_file_text : mst_text,
+                          symbol.n_scnum, objfile);
+                       misc_func_recorded = 1;
+                     }
                    break;
 
                  case XMC_GL:
@@ -2386,11 +2418,10 @@ scan_xcoff_symtab (struct objfile *objfile)
                       mst_solib_trampoline symbol.  When we lookup mst
                       symbols, we will choose mst_text over
                       mst_solib_trampoline.  */
-                   RECORD_MINIMAL_SYMBOL
+                   record_minimal_symbol
                      (namestring, symbol.n_value,
-                      mst_solib_trampoline,
-                      secnum_to_section (symbol.n_scnum, objfile),
-                      objfile);
+                      mst_solib_trampoline, symbol.n_scnum, objfile);
+                   misc_func_recorded = 1;
                    break;
 
                  case XMC_DS:
@@ -2413,7 +2444,8 @@ scan_xcoff_symtab (struct objfile *objfile)
                        (namestring, symbol.n_value,
                         sclass == C_HIDEXT ? mst_file_data : mst_data,
                         secnum_to_section (symbol.n_scnum, objfile),
-                        NULL, objfile);
+                        secnum_to_bfd_section (symbol.n_scnum, objfile),
+                        objfile);
                    break;
                  }
                break;
@@ -2430,7 +2462,8 @@ scan_xcoff_symtab (struct objfile *objfile)
                        (namestring, symbol.n_value,
                         sclass == C_HIDEXT ? mst_file_bss : mst_bss,
                         secnum_to_section (symbol.n_scnum, objfile),
-                        NULL, objfile);
+                        secnum_to_bfd_section (symbol.n_scnum, objfile),
+                        objfile);
                    break;
                  }
                break;
@@ -2456,9 +2489,9 @@ scan_xcoff_symtab (struct objfile *objfile)
                   it as a function.  This will take care of functions like
                   strcmp() compiled by xlc.  */
 
-               RECORD_MINIMAL_SYMBOL
-                 (last_csect_name, last_csect_val,
-                  mst_text, last_csect_sec, objfile);
+               record_minimal_symbol (last_csect_name, last_csect_val,
+                                      mst_text, last_csect_sec, objfile);
+               misc_func_recorded = 1;
              }
 
            if (pst)
@@ -3103,6 +3136,7 @@ static const struct sym_fns xcoff_sym_fns =
   default_symfile_segments,    /* Get segment information from a file.  */
   aix_process_linenos,
   default_symfile_relocate,    /* Relocate a debug section.  */
+  NULL,                                /* sym_probe_fns */
   &psym_functions
 };
 
This page took 0.026329 seconds and 4 git commands to generate.