* symfile.c (reread_symbols): When re-reading symbols, do all the
[binutils-gdb.git] / gdb / minsyms.c
index 63850aa528d39a172594cec78c02367c6e3b619e..dbb4e797d9709e8308972005f56f519b90ae85ed 100644 (file)
@@ -212,7 +212,7 @@ lookup_minimal_symbol_by_pc (pc)
        {
          lo = 0;
          hi = objfile -> minimal_symbol_count - 1;
-         
+
          /* This code assumes that the minimal symbols are sorted by
             ascending address values.  If the pc value is greater than or
             equal to the first symbol's address, then some symbol in this
@@ -253,14 +253,28 @@ lookup_minimal_symbol_by_pc (pc)
                 objfile's minimal symbol table.  See if it is the best one
                 overall. */
 
-             if ((best_symbol == NULL) ||
-                 (SYMBOL_VALUE_ADDRESS (best_symbol) < 
-                  SYMBOL_VALUE_ADDRESS (&msymbol[hi])))
+             /* Skip any absolute symbols.  This is apparently what adb
+                and dbx do, and is needed for the CM-5.  There are two
+                known possible problems: (1) on ELF, apparently end, edata,
+                etc. are absolute.  Not sure ignoring them here is a big
+                deal, but if we want to use them, the fix would go in
+                elfread.c.  (2) I think shared library entry points on the
+                NeXT are absolute.  If we want special handling for this
+                it probably should be triggered by a special
+                mst_abs_or_lib or some such.  */
+             while (hi >= 0
+                    && msymbol[hi].type == mst_abs)
+               --hi;
+
+             if (hi >= 0
+                 && ((best_symbol == NULL) ||
+                     (SYMBOL_VALUE_ADDRESS (best_symbol) < 
+                      SYMBOL_VALUE_ADDRESS (&msymbol[hi]))))
                {
                  best_symbol = &msymbol[hi];
                }
            }
-       }      
+       }
     }
   return (best_symbol);
 }