202001-10-15 Jim Ingham <jingham@inghji.apple.com>
[deliverable/binutils-gdb.git] / gdb / partial-stab.h
index 5dadf44c7e89925eddb74a2d78337b55599f6cbc..e18cabbba097f0e6221562eaa2f40794fa38461c 100644 (file)
@@ -40,6 +40,9 @@
 
 switch (CUR_SYMBOL_TYPE)
   {
+    static struct complaint function_outside_compilation_unit = {
+      "function `%s' appears to be defined outside of all compilation units", 0, 0
+    };
     char *p;
     /*
      * Standard, external, non-debugger, symbols
@@ -198,7 +201,7 @@ switch (CUR_SYMBOL_TYPE)
 
   case N_SO:
     {
-      unsigned long valu;
+      CORE_ADDR valu;
       static int prev_so_symnum = -10;
       static int first_so_symnum;
       char *p;
@@ -396,7 +399,7 @@ switch (CUR_SYMBOL_TYPE)
     /* See if this is an end of function stab.  */
     if (pst && CUR_SYMBOL_TYPE == N_FUN && *namestring == '\000')
       {
-       unsigned long valu;
+       CORE_ADDR valu;
 
        /* It's value is the size (in bytes) of the function for
           function relative stabs, or the address of the function's
@@ -576,6 +579,15 @@ switch (CUR_SYMBOL_TYPE)
        continue;
 
       case 'f':
+        if (! pst)
+          {
+            int name_len = p - namestring;
+            char *name = xmalloc (name_len + 1);
+            memcpy (name, namestring, name_len);
+            name[name_len] = '\0';
+            complain (&function_outside_compilation_unit, name);
+            xfree (name);
+          }
        CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 #ifdef DBXREAD_ONLY
        /* Kludges for ELF/STABS with Sun ACC */
@@ -583,10 +595,22 @@ switch (CUR_SYMBOL_TYPE)
 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
        /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
           value for the bottom of the text seg in those cases. */
-       if (pst && textlow_not_set)
+       if (CUR_SYMBOL_VALUE == ANOFFSET (objfile->section_offsets, 
+                                         SECT_OFF_TEXT (objfile)))
          {
-           pst->textlow =
+           CORE_ADDR minsym_valu = 
              find_stab_function_addr (namestring, pst->filename, objfile);
+           /* find_stab_function_addr will return 0 if the minimal
+              symbol wasn't found.  (Unfortunately, this might also
+              be a valid address.)  Anyway, if it *does* return 0,
+              it is likely that the value was set correctly to begin
+              with... */
+           if (minsym_valu != 0)
+             CUR_SYMBOL_VALUE = minsym_valu;
+         }
+       if (pst && textlow_not_set)
+         {
+           pst->textlow = CUR_SYMBOL_VALUE;
            textlow_not_set = 0;
          }
 #endif
@@ -601,10 +625,11 @@ switch (CUR_SYMBOL_TYPE)
           use the address of this function as the low bound for
           the partial symbol table.  */
        if (pst
-           && (textlow_not_set
-               || (pst && CUR_SYMBOL_VALUE < pst->textlow
-                 && CUR_SYMBOL_VALUE
-                 != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))))
+            && (textlow_not_set
+                || (CUR_SYMBOL_VALUE < pst->textlow
+                    && (CUR_SYMBOL_VALUE
+                        != ANOFFSET (objfile->section_offsets,
+                                     SECT_OFF_TEXT (objfile))))))
          {
            pst->textlow = CUR_SYMBOL_VALUE;
            textlow_not_set = 0;
@@ -621,6 +646,15 @@ switch (CUR_SYMBOL_TYPE)
           are put into the global psymtab like one would expect.
           They're also in the minimal symbol table.  */
       case 'F':
+        if (! pst)
+          {
+            int name_len = p - namestring;
+            char *name = xmalloc (name_len + 1);
+            memcpy (name, namestring, name_len);
+            name[name_len] = '\0';
+            complain (&function_outside_compilation_unit, name);
+            xfree (name);
+          }
        CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 #ifdef DBXREAD_ONLY
        /* Kludges for ELF/STABS with Sun ACC */
@@ -630,8 +664,17 @@ switch (CUR_SYMBOL_TYPE)
           value for the bottom of the text seg in those cases. */
        if (CUR_SYMBOL_VALUE == ANOFFSET (objfile->section_offsets, 
                                          SECT_OFF_TEXT (objfile)))
-         CUR_SYMBOL_VALUE = 
-           find_stab_function_addr (namestring, pst->filename, objfile);
+         {
+           CORE_ADDR minsym_valu = 
+             find_stab_function_addr (namestring, pst->filename, objfile);
+           /* find_stab_function_addr will return 0 if the minimal
+              symbol wasn't found.  (Unfortunately, this might also
+              be a valid address.)  Anyway, if it *does* return 0,
+              it is likely that the value was set correctly to begin
+              with... */
+           if (minsym_valu != 0)
+             CUR_SYMBOL_VALUE = minsym_valu;
+         }
        if (pst && textlow_not_set)
          {
            pst->textlow = CUR_SYMBOL_VALUE;
@@ -648,10 +691,12 @@ switch (CUR_SYMBOL_TYPE)
           the bounds created by N_SO symbols.  If that's the case
           use the address of this function as the low bound for
           the partial symbol table.  */
-       if (textlow_not_set
-           || (pst && CUR_SYMBOL_VALUE < pst->textlow
-               && CUR_SYMBOL_VALUE
-               != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))))
+       if (pst
+            && (textlow_not_set
+                || (CUR_SYMBOL_VALUE < pst->textlow
+                    && (CUR_SYMBOL_VALUE
+                        != ANOFFSET (objfile->section_offsets,
+                                     SECT_OFF_TEXT (objfile))))))
          {
            pst->textlow = CUR_SYMBOL_VALUE;
            textlow_not_set = 0;
This page took 0.030096 seconds and 4 git commands to generate.