--- ./gdb/xcoffread.c_orig	2012-11-26 15:48:16 +0500
+++ ./gdb/xcoffread.c	2012-11-26 15:58:40 +0500
@@ -1177,22 +1177,6 @@
 		         approach does not work!  GCC (and I think xlc) seem
 		         to put all the code in the unnamed program csect.  */
 
-		      if (last_csect_name)
-			{
-			  complete_symtab (filestring, file_start_addr);
-			  cur_src_end_addr = file_end_addr;
-			  end_symtab (file_end_addr, objfile,
-				      SECT_OFF_TEXT (objfile));
-			  end_stabs ();
-			  start_stabs ();
-			  /* Give all csects for this source file the same
-			     name.  */
-			  start_symtab (filestring, NULL, (CORE_ADDR) 0);
-			  record_debugformat (debugfmt);
-			}
-
-		      /* If this is the very first csect seen,
-		         basically `__start'.  */
 		      if (just_started)
 			{
 			  first_object_file_end
@@ -1207,7 +1191,24 @@
 
 		      if (cs->c_name && (cs->c_name[0] == '.' || cs->c_name[0] == '@'))
 			last_csect_name = cs->c_name;
+                      if (last_csect_name)
+		      {
+                          filestring = pst->filename;
+                          complete_symtab (filestring, file_start_addr);
+                          cur_src_end_addr = file_end_addr;
+                          end_symtab (file_end_addr, objfile,
+                                      SECT_OFF_TEXT (objfile));
+                          end_stabs ();
+                          start_stabs ();
+                          /* Give all csects for this source file the same
+                             name.  */
+                          start_symtab (filestring, (char *)NULL, (CORE_ADDR) 0);
+                          record_debugformat (debugfmt);
+                       }
+                      /* If this is the very first csect seen,
+                         basically `__start'.  */
 		    }
+
 		    continue;
 
 		    /* All other symbols are put into the minimal symbol
