2003-09-12 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 836c26e825cd13bd660a2f6055505a9cb7f79689..e2fbc2ae2eefb5ba7a2fd36cf87d5a6def7d39fe 100644 (file)
@@ -236,38 +236,6 @@ sort_pst_symbols (struct partial_symtab *pst)
         compare_psymbols);
 }
 
-/* Call sort_block_syms to sort alphabetically the symbols of one block.  */
-
-void
-sort_block_syms (register struct block *b)
-{
-  qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b),
-        sizeof (struct symbol *), compare_symbols);
-}
-
-/* Call sort_symtab_syms to sort alphabetically
-   the symbols of each block of one symtab.  */
-
-void
-sort_symtab_syms (register struct symtab *s)
-{
-  register struct blockvector *bv;
-  int nbl;
-  int i;
-  register struct block *b;
-
-  if (s == 0)
-    return;
-  bv = BLOCKVECTOR (s);
-  nbl = BLOCKVECTOR_NBLOCKS (bv);
-  for (i = 0; i < nbl; i++)
-    {
-      b = BLOCKVECTOR_BLOCK (bv, i);
-      if (BLOCK_SHOULD_SORT (b))
-       sort_block_syms (b);
-    }
-}
-
 /* Make a null terminated copy of the string at PTR with SIZE characters in
    the obstack pointed to by OBSTACKP .  Returns the address of the copy.
    Note that the string at PTR does not have to be null terminated, I.E. it
@@ -359,8 +327,8 @@ init_entry_point_info (struct objfile *objfile)
       /* Examination of non-executable.o files.  Short-circuit this stuff.  */
       objfile->ei.entry_point = INVALID_ENTRY_POINT;
     }
-  objfile->ei.entry_file_lowpc = INVALID_ENTRY_LOWPC;
-  objfile->ei.entry_file_highpc = INVALID_ENTRY_HIGHPC;
+  objfile->ei.deprecated_entry_file_lowpc = INVALID_ENTRY_LOWPC;
+  objfile->ei.deprecated_entry_file_highpc = INVALID_ENTRY_HIGHPC;
   objfile->ei.entry_func_lowpc = INVALID_ENTRY_LOWPC;
   objfile->ei.entry_func_highpc = INVALID_ENTRY_HIGHPC;
   objfile->ei.main_func_lowpc = INVALID_ENTRY_LOWPC;
@@ -598,12 +566,8 @@ syms_from_objfile (struct objfile *objfile,
                   int mainline,
                    int verbo)
 {
-  asection *lower_sect;
-  asection *sect;
-  CORE_ADDR lower_offset;
   struct section_addr_info *local_addr = NULL;
   struct cleanup *old_chain;
-  int i;
 
   gdb_assert (! (addrs && offsets));
 
@@ -658,8 +622,13 @@ syms_from_objfile (struct objfile *objfile,
 
      We no longer warn if the lowest section is not a text segment (as
      happens for the PA64 port.  */
-  if (!mainline)
+  if (!mainline && addrs && addrs->other[0].name)
     {
+      asection *lower_sect;
+      asection *sect;
+      CORE_ADDR lower_offset;
+      int i;
+
       /* Find lowest loadable section to be used as starting point for 
          continguous sections. FIXME!! won't work without call to find
         .text first, but this assumes text is lowest section. */
@@ -691,9 +660,7 @@ syms_from_objfile (struct objfile *objfile,
         (the loadable section directly below it in memory).
         this_offset = lower_offset = lower_addr - lower_orig_addr */
 
-      /* Calculate offsets for sections. */
-      if (addrs)
-        for (i=0 ; i < addrs->num_sections && addrs->other[i].name; i++)
+        for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
           {
             if (addrs->other[i].addr != 0)
               {
@@ -743,7 +710,7 @@ syms_from_objfile (struct objfile *objfile,
       init_objfile_sect_indices (objfile);
     }
 
-#ifndef IBM6000_TARGET
+#ifndef DEPRECATED_IBM6000_TARGET
   /* This is a SVR4/SunOS specific hack, I think.  In any event, it
      screws RS/6000.  sym_offsets should be doing this sort of thing,
      because it knows the mapping between bfd sections and
@@ -791,7 +758,7 @@ syms_from_objfile (struct objfile *objfile,
          s->offset += s_addr;
        }
     }
-#endif /* not IBM6000_TARGET */
+#endif /* not DEPRECATED_IBM6000_TARGET */
 
   (*objfile->sf->sym_read) (objfile, mainline);
 
@@ -887,7 +854,12 @@ symbol_file_add_with_addrs_or_offsets (char *name, int from_tty,
   orig_addrs = alloc_section_addr_info (bfd_count_sections (abfd));
   my_cleanups = make_cleanup (xfree, orig_addrs);
   if (addrs)
-    *orig_addrs = *addrs;
+    {
+      int i;
+      orig_addrs->num_sections = addrs->num_sections;
+      for (i = 0; i < addrs->num_sections; i++)
+       orig_addrs->other[i] = addrs->other[i];
+    }
 
   /* If the objfile uses a mapped symbol file, and we have a psymtab for
      it, then skip reading any symbols at this time. */
@@ -1410,10 +1382,6 @@ find_sym_fns (struct objfile *objfile)
       || our_flavour == bfd_target_tekhex_flavour)
     return;    /* No symbols. */
 
-  /* Special kludge for apollo.  See dstread.c.  */
-  if (STREQN (our_target, "apollo", 6))
-    our_flavour = (enum bfd_flavour) -2;
-
   for (sf = symtab_fns; sf != NULL; sf = sf->next)
     {
       if (our_flavour == sf->sym_flavour)
@@ -1839,11 +1807,7 @@ add_symbol_file_command (char *args, int from_tty)
       char *val = sect_opts[i].value;
       char *sec = sect_opts[i].name;
  
-      val = sect_opts[i].value;
-      if (val[0] == '0' && val[1] == 'x')
-       addr = strtoul (val+2, NULL, 16);
-      else
-       addr = strtoul (val, NULL, 10);
+      addr = parse_and_eval_address (val);
 
       /* Here we store the section offsets in the order they were
          entered on the command line. */
@@ -1902,7 +1866,7 @@ reread_symbols (void)
     {
       if (objfile->obfd)
        {
-#ifdef IBM6000_TARGET
+#ifdef DEPRECATED_IBM6000_TARGET
          /* If this object is from a shared library, then you should
             stat on the library name, not member name. */
 
@@ -1999,6 +1963,7 @@ reread_symbols (void)
              objfile->psymtabs = NULL;
              objfile->free_psymtabs = NULL;
              objfile->msymbols = NULL;
+             objfile->sym_private = NULL;
              objfile->minimal_symbol_count = 0;
              memset (&objfile->msymbol_hash, 0,
                      sizeof (objfile->msymbol_hash));
@@ -2667,9 +2632,21 @@ start_psymtab_common (struct objfile *objfile,
 }
 \f
 /* Add a symbol with a long value to a psymtab.
-   Since one arg is a struct, we pass in a ptr and deref it (sigh).  */
-
-void
+   Since one arg is a struct, we pass in a ptr and deref it (sigh).  
+   Return the partial symbol that has been added.  */
+
+/* NOTE: carlton/2003-09-11: The reason why we return the partial
+   symbol is so that callers can get access to the symbol's demangled
+   name, which they don't have any cheap way to determine otherwise.
+   (Currenly, dwarf2read.c is the only file who uses that information,
+   though it's possible that other readers might in the future.)
+   Elena wasn't thrilled about that, and I don't blame her, but we
+   couldn't come up with a better way to get that information.  If
+   it's needed in other situations, we could consider breaking up
+   SYMBOL_SET_NAMES to provide access to the demangled name lookup
+   cache.  */
+
+const struct partial_symbol *
 add_psymbol_to_list (char *name, int namelength, domain_enum domain,
                     enum address_class class,
                     struct psymbol_allocation_list *list, long val,    /* Value as a long */
@@ -2712,6 +2689,8 @@ add_psymbol_to_list (char *name, int namelength, domain_enum domain,
     }
   *list->next++ = psym;
   OBJSTAT (objfile, n_psyms++);
+
+  return psym;
 }
 
 /* Add a symbol with a long value to a psymtab. This differs from
@@ -3010,7 +2989,7 @@ pc_in_mapped_range (CORE_ADDR pc, asection *section)
 
 /* Return true if the mapped ranges of sections A and B overlap, false
    otherwise.  */
-int
+static int
 sections_overlap (asection *a, asection *b)
 {
   /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
This page took 0.025973 seconds and 4 git commands to generate.