diff --exclude='*.o' -pur gdb-5.2.1.orig/gdb/dbxread.c gdb-5.2.1/gdb/dbxread.c
--- gdb-5.2.1.orig/gdb/dbxread.c	Fri Apr  5 00:33:49 2002
+++ gdb-5.2.1/gdb/dbxread.c	Tue Sep 30 10:49:38 2003
@@ -1249,6 +1249,11 @@ read_dbx_symtab (struct objfile *objfile
   struct cleanup *back_to;
   bfd *abfd;
   int textlow_not_set;
+  unsigned long prev_texthigh = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  /* This is used to pass zero 'textlow_not_set' to end_psymtab for .s files. 
+   * Otherwise it is treated as data-only psymtab record (textlow = texthigh).
+   */
+  int notdatafile = 0;
 
   /* Current partial symtab */
   struct partial_symtab *pst;
@@ -1314,7 +1319,9 @@ read_dbx_symtab (struct objfile *objfile
       if (bfd_h_get_8 (abfd, bufp->e_type) == N_SLINE)
 	{
 	  has_line_numbers = 1;
+#if 0
 	  continue;
+#endif
 	}
 
       INTERNALIZE_SYMBOL (nlist, bufp, abfd);
@@ -1402,7 +1409,14 @@ read_dbx_symtab (struct objfile *objfile
 			     symnum * symbol_size,
 			     nlist.n_value > TEXTHIGH (pst)
 			     ? nlist.n_value : TEXTHIGH (pst),
-			     dependency_list, dependencies_used, textlow_not_set);
+			     dependency_list, dependencies_used, notdatafile ? 0 : textlow_not_set);
+	    /* .s files. */
+	    if (TEXTHIGH(pst) && !TEXTLOW(pst))
+	      TEXTLOW(pst) = prev_texthigh;
+	    if (notdatafile)
+	      prev_texthigh = TEXTHIGH(pst);
+	    notdatafile = 0;
+
 		pst = (struct partial_symtab *) 0;
 		includes_used = 0;
 		dependencies_used = 0;
@@ -1525,7 +1539,16 @@ read_dbx_symtab (struct objfile *objfile
 				 symnum * symbol_size,
 				 valu > TEXTHIGH (pst) ? valu : TEXTHIGH (pst),
 				 dependency_list, dependencies_used,
-				 prev_textlow_not_set);
+				 notdatafile ? 0 : prev_textlow_not_set);
+	      /* .s files. texthigh is set but textlow isn't.
+	       * This is not a data-only record, fixup textlow.
+	       */
+		    if (TEXTHIGH(pst) && !TEXTLOW(pst))
+		      TEXTLOW(pst) = prev_texthigh;
+		    if (notdatafile) 
+		      prev_texthigh = TEXTHIGH(pst);
+		    notdatafile = 0;
+
 		    pst = (struct partial_symtab *) 0;
 		    includes_used = 0;
 		    dependencies_used = 0;
@@ -2091,7 +2114,13 @@ read_dbx_symtab (struct objfile *objfile
 	    end_psymtab (pst, psymtab_include_list, includes_used,
 			 symnum * symbol_size,
 			 (CORE_ADDR) 0,
-			 dependency_list, dependencies_used, textlow_not_set);
+			 dependency_list, dependencies_used, notdatafile ? 0 : textlow_not_set);
+	/* .s files */
+	    if (TEXTHIGH(pst) && !TEXTLOW(pst))
+	      TEXTLOW(pst) = prev_texthigh;
+	    if (notdatafile)
+	      prev_texthigh = TEXTHIGH(pst);
+
 	    pst = (struct partial_symtab *) 0;
 	    includes_used = 0;
 	    dependencies_used = 0;
@@ -2118,7 +2147,13 @@ read_dbx_symtab (struct objfile *objfile
 	  case N_ECOMM:
 	  case N_ECOML:
 	  case N_FNAME:
+	  continue;
 	  case N_SLINE:
+	  /* .s files */
+	   notdatafile = 1;
+	  if (pst)
+	    TEXTHIGH(pst) = prev_texthigh + nlist.n_value + 4;
+	  continue;
 	  case N_RSYM:
 	  case N_PSYM:
 	  case N_LBRAC:
@@ -2164,7 +2199,10 @@ read_dbx_symtab (struct objfile *objfile
       end_psymtab (pst, psymtab_include_list, includes_used,
 		   symnum * symbol_size,
 		   text_end > TEXTHIGH (pst) ? text_end : TEXTHIGH (pst),
-		   dependency_list, dependencies_used, textlow_not_set);
+		   dependency_list, dependencies_used, notdatafile ? 0 : textlow_not_set);
+      /* .s files */
+      if (TEXTHIGH(pst) && !TEXTLOW(pst))
+        TEXTLOW(pst) = prev_texthigh;
     }
 
   do_cleanups (back_to);
@@ -2207,7 +2245,9 @@ start_psymtab (struct objfile *objfile, 
   /* Deduce the source language from the filename for this psymtab. */
   psymtab_language = deduce_language_from_filename (filename);
 
-  return result;
+ /* otherwise it is possible to come to end_psymtab uninitialized */
+ last_function_name = NULL;
+ return result;
 }
 
 /* Close off the current usage of PST.  
@@ -2600,7 +2640,7 @@ read_ofile_symtab (struct partial_symtab
       if (type & N_STAB)
 	{
 	  process_one_symbol (type, nlist.n_desc, nlist.n_value,
-			      namestring, section_offsets, objfile);
+			      namestring, section_offsets, objfile, text_offset);
 	}
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
@@ -2686,7 +2726,7 @@ read_ofile_symtab (struct partial_symtab
 void
 process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 		    struct section_offsets *section_offsets,
-		    struct objfile *objfile)
+		    struct objfile *objfile, CORE_ADDR text_low)
 {
 #ifdef SUN_FIXED_LBRAC_BUG
   /* If SUN_FIXED_LBRAC_BUG is defined, then it tells us whether we need
@@ -2960,6 +3000,13 @@ process_one_symbol (int type, int desc, 
          one line-number -- core-address correspondence.
          Enter it in the line list for this symbol table.  */
 
+      /* Records in .o file compiled form .s are not relocated, do it now.
+         The last condition is to filter out the full-linked image case
+         where the .s records _are_ relocated. */
+      if (!function_start_offset && text_low && !valu) {
+        function_start_offset = text_low;
+      }
+
       /* Relocate for dynamic loading and for ELF acc fn-relative syms.  */
       valu += function_start_offset;
 
@@ -2974,7 +3021,10 @@ process_one_symbol (int type, int desc, 
 	  sline_found_in_function = 1;
 	}
       else
-	record_line (current_subfile, desc, valu);
+    /* adjust valu when we have only SLINE info (.s file compiled with -g) */
+	record_line (current_subfile, desc, 
+	  (function_start_offset) ? valu : 
+	  valu + ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)));
       break;
 
     case N_BCOMM:
diff --exclude='*.o' -pur gdb-5.2.1.orig/gdb/mdebugread.c gdb-5.2.1/gdb/mdebugread.c
--- gdb-5.2.1.orig/gdb/mdebugread.c	Sun Jun 16 16:13:59 2002
+++ gdb-5.2.1/gdb/mdebugread.c	Fri Sep 26 14:28:16 2003
@@ -2239,6 +2239,8 @@ parse_partial_symbols (struct objfile *o
   enum language prev_language;
   asection *text_sect;
   int relocatable = 0;
+  unsigned long prev_texthigh = 0;
+  int notdatafile = 0;
 
   /* Irix 5.2 shared libraries have a fh->adr field of zero, but
      the shared libraries are prelinked at a high memory address.
@@ -3923,14 +3925,14 @@ psymtab_to_symtab_1 (struct partial_symt
 		    {
 		      last_symtab_ended = 0;
 		      process_one_symbol (type_code, 0, valu, name,
-					  pst->section_offsets, pst->objfile);
+					  pst->section_offsets, pst->objfile, pst->textlow);
 		    }
 		}
 	      /* Similarly a hack.  */
 	      else if (name[0] == '#')
 		{
 		  process_one_symbol (N_SLINE, 0, valu, name,
-				      pst->section_offsets, pst->objfile);
+				      pst->section_offsets, pst->objfile, pst->textlow);
 		}
 	      if (type_code == N_FUN)
 		{
--- gdb-5.2.1.orig/gdb/stabsread.h.orig	Tue Sep 30 15:00:01 2003
+++ gdb-5.2.1/gdb/stabsread.h	Tue Sep 30 10:50:46 2003
@@ -184,7 +184,7 @@ extern struct partial_symtab *end_psymta
 
 extern void
 process_one_symbol (int, int, CORE_ADDR, char *,
-		    struct section_offsets *, struct objfile *);
+		    struct section_offsets *, struct objfile *, CORE_ADDR);
 
 extern void elfstab_build_psymtabs
   (struct objfile *objfile,
