]> Git Repo - binutils.git/blobdiff - gdb/stabsread.c
* elfcode.h (assign_section_numbers): Put shstrtab, symtab and
[binutils.git] / gdb / stabsread.c
index 6466e37b232d84da03a192a14c31bf30001cd5bf..a1b1775af8b31f583088ca98c64131adbc3942ce 100644 (file)
@@ -33,6 +33,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "symfile.h"
 #include "objfiles.h"
 #include "aout/stab_gnu.h"     /* We always use GNU stabs, not native */
+#include "libaout.h"
+#include "aout/aout64.h"
+#include "gdb-stabs.h"
 #include "buildsym.h"
 #include "complaints.h"
 #include "demangle.h"
@@ -399,13 +402,13 @@ patch_block_stabs (symbols, stabs, objfile)
          sym = find_symbol_in_list (symbols, name, pp-name);
          if (!sym)
            {
-#if 0
-             /* The following code is disabled because AIX's xlc also
-                puts out a stab but no C_EXT in the case where a
-                symbol is referenced but not defined (in that
-                compilation unit).  So we just don't create a symbol,
-                and the user will get the symbol from the compilation
-                unit in which the symbol is actually defined.  */
+             /* FIXME-maybe: it would be nice if we noticed whether
+                the variable was defined *anywhere*, not just whether
+                it is defined in this compilation unit.  But neither
+                xlc or GCC seem to need such a definition, and until
+                we do psymtabs (so that the minimal symbols from all
+                compilation units are available now), I'm not sure
+                how to get the information.  */
 
              /* On xcoff, if a global is defined and never referenced,
                 ld will remove it from the executable.  There is then
@@ -433,7 +436,6 @@ patch_block_stabs (symbols, stabs, objfile)
                  SYMBOL_TYPE (sym) = read_type (&pp, objfile);
                }
              add_symbol_to_list (sym, &global_symbols);
-#endif /* 0 */
            }
          else
            {
@@ -541,6 +543,19 @@ define_symbol (valu, string, desc, type, objfile)
     obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
   memset (sym, 0, sizeof (struct symbol));
 
+  switch (type & N_TYPE)
+    {
+    case N_TEXT:
+      SYMBOL_SECTION(sym) = SECT_OFF_TEXT;
+      break;
+    case N_DATA:
+      SYMBOL_SECTION(sym) = SECT_OFF_DATA;
+      break;
+    case N_BSS:
+      SYMBOL_SECTION(sym) = SECT_OFF_BSS;
+      break;
+    }
+
   if (processing_gcc_compilation)
     {
       /* GCC 2.x puts the line number in desc.  SunOS apparently puts in the
@@ -978,9 +993,11 @@ define_symbol (valu, string, desc, type, objfile)
          /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
             name to represent an argument passed in a register.
             GCC uses 'P' for the same case.  So if we find such a symbol pair
-            we combine it into one 'P' symbol.
+            we combine it into one 'P' symbol.  For Sun cc we need to do this
+            regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
+            the 'p' symbol even if it never saves the argument onto the stack.
 
-            But we only do this in the REG_STRUCT_HAS_ADDR case, so that
+            On most machines, we want to preserve both symbols, so that
             we can still get information about what is going on with the
             stack (VAX for computing args_printed, using stack slots instead
             of saved registers in backtraces, etc.).
@@ -992,14 +1009,18 @@ define_symbol (valu, string, desc, type, objfile)
 
          if (local_symbols
              && local_symbols->nsyms > 0
+#ifndef USE_REGISTER_NOT_ARG
              && REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
                                      SYMBOL_TYPE (sym))
              && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
-                 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION))
+                 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
+#endif
+             )
            {
              struct symbol *prev_sym;
              prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
-             if (SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
+             if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
+                  || SYMBOL_CLASS (prev_sym) == LOC_ARG)
                  && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME(sym)))
                {
                  SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
@@ -1054,7 +1075,13 @@ define_symbol (valu, string, desc, type, objfile)
 
       if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
        {
-         if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
+         /* gcc-2.6 or later (when using -fvtable-thunks)
+            emits a unique named type for a vtable entry.
+            Some gdb code depends on that specific name. */
+         extern const char vtbl_ptr_name[];
+
+         if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
+              && strcmp (SYMBOL_NAME (sym), vtbl_ptr_name))
              || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)
            {
              /* If we are giving a name to a type such as "pointer to
@@ -1488,7 +1515,7 @@ read_type (pp, objfile)
 
        if (typenums[0] == xtypenums[0] && typenums[1] == xtypenums[1])
          /* It's being defined as itself.  That means it is "void".  */
-         type = init_type (TYPE_CODE_VOID, 0, 0, NULL, objfile);
+         type = init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
        else
          {
            struct type *xtype;
@@ -1540,13 +1567,17 @@ read_type (pp, objfile)
     case 'f':                          /* Function returning another type */
       if (os9k_stabs && **pp == '(')
        {
-         /* Function prototype; skip it.
+         /* Function prototype; parse it.
             We must conditionalize this on os9k_stabs because otherwise
             it could be confused with a Sun-style (1,3) typenumber
             (I think).  */
-         while (**pp != ')')
-           ++*pp;
+         struct type *t;
          ++*pp;
+         while (**pp != ')')
+            {
+              t = read_type(pp, objfile);
+              if (**pp == ',') ++*pp;
+            }
        }
       type1 = read_type (pp, objfile);
       type = make_function_type (type1, dbx_lookup_type (typenums));
@@ -1784,7 +1815,7 @@ rs6000_builtin_type (typenum)
                           "unsigned long", NULL);
       break;
     case 11:
-      rettype = init_type (TYPE_CODE_VOID, 0, 0, "void", NULL);
+      rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
       break;
     case 12:
       /* IEEE single precision (32 bit).  */
@@ -3151,10 +3182,15 @@ read_sun_builtin_type (pp, typenums, objfile)
   if (**pp == ';')
     ++(*pp);
 
-  return init_type (type_bits == 0 ? TYPE_CODE_VOID : TYPE_CODE_INT,
-                   type_bits / TARGET_CHAR_BIT,
-                   signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *)NULL,
-                   objfile);
+  if (type_bits == 0)
+    return init_type (TYPE_CODE_VOID, 1,
+                     signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *)NULL,
+                     objfile);
+  else
+    return init_type (TYPE_CODE_INT,
+                     type_bits / TARGET_CHAR_BIT,
+                     signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *)NULL,
+                     objfile);
 }
 
 static struct type *
@@ -3372,7 +3408,7 @@ read_range_type (pp, typenums, objfile)
 
   /* A type defined as a subrange of itself, with bounds both 0, is void.  */
   if (self_subrange && n2 == 0 && n3 == 0)
-    return init_type (TYPE_CODE_VOID, 0, 0, NULL, objfile);
+    return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
 
   /* If n3 is zero and n2 is not, we want a floating type,
      and n2 is the width in bytes.
@@ -3812,6 +3848,8 @@ scan_file_globals (objfile)
                {
                  SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msymbol);
                }
+
+             SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
              
              if (prev)
                {
This page took 0.031429 seconds and 4 git commands to generate.