43873a6
2004-11-24  Andrew Cagney  <cagney@gnu.org>
43873a6
43873a6
	* printcmd.c (build_address_symbolic): Find a section for the
43873a6
	address.
43873a6
43873a6
--- ./gdb/printcmd.c.1	2004-11-24 17:54:27.316295608 -0500
43873a6
+++ ./gdb/printcmd.c	2004-11-24 17:59:20.069790312 -0500
43873a6
@@ -615,6 +615,20 @@
43873a6
 	  addr = overlay_mapped_address (addr, section);
43873a6
 	}
43873a6
     }
43873a6
+  /* To ensure that the symbol returned belongs to the correct setion
43873a6
+     (and that the last [random] symbol from the previous section
43873a6
+     isn't returned) try to find the section containing PC.  First try
43873a6
+     the overlay code (which by default returns NULL); and second try
43873a6
+     the normal section code (which almost always succeeds).  */
43873a6
+  section = find_pc_overlay (addr);
43873a6
+  if (section == NULL)
43873a6
+    {
43873a6
+      struct obj_section *obj_section = find_pc_section (addr);
43873a6
+      if (obj_section == NULL)
43873a6
+	section = NULL;
43873a6
+      else
43873a6
+	section = obj_section->the_bfd_section;
43873a6
+    }
43873a6
 
43873a6
   /* First try to find the address in the symbol table, then
43873a6
      in the minsyms.  Take the closest one.  */