diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 170ba3a..8bca5b2 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -151,13 +151,13 @@ debug_qf_map_symtabs_matching_filename (struct objfile *objfile,
   return retval;
 }
 
-static struct symtab *
+static struct compunit_symtab *
 debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
 			domain_enum domain)
 {
   const struct debug_sym_fns_data *debug_data =
     objfile_data (objfile, symfile_debug_objfile_data_key);
-  struct symtab *retval;
+  struct compunit_symtab *retval;
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
@@ -168,7 +168,9 @@ debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
 						   domain);
 
   fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
-		    retval ? debug_symtab_name (retval) : "NULL");
+		    retval
+		    ? debug_symtab_name (compunit_primary_filetab (retval))
+		    : "NULL");
 
   return retval;
 }
@@ -306,31 +308,35 @@ debug_qf_expand_symtabs_matching
 						    kind, data);
 }
 
-static struct symtab *
-debug_qf_find_pc_sect_symtab (struct objfile *objfile,
-			      struct bound_minimal_symbol msymbol,
-			      CORE_ADDR pc,
-			      struct obj_section *section,
-			      int warn_if_readin)
+static struct compunit_symtab *
+debug_qf_find_pc_sect_compunit_symtab (struct objfile *objfile,
+				       struct bound_minimal_symbol msymbol,
+				       CORE_ADDR pc,
+				       struct obj_section *section,
+				       int warn_if_readin)
 {
   const struct debug_sym_fns_data *debug_data =
     objfile_data (objfile, symfile_debug_objfile_data_key);
-  struct symtab *retval;
+  struct compunit_symtab *retval;
 
   fprintf_filtered (gdb_stdlog,
-		    "qf->find_pc_sect_symtab (%s, %s, %s, %s, %d)\n",
+		    "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
 		    debug_objfile_name (objfile),
 		    host_address_to_string (msymbol.minsym),
 		    hex_string (pc),
 		    host_address_to_string (section),
 		    warn_if_readin);
 
-  retval = debug_data->real_sf->qf->find_pc_sect_symtab (objfile, msymbol,
-							 pc, section,
-							 warn_if_readin);
+  retval
+    = debug_data->real_sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
+							     pc, section,
+							     warn_if_readin);
 
-  fprintf_filtered (gdb_stdlog, "qf->find_pc_sect_symtab (...) = %s\n",
-		    retval ? debug_symtab_name (retval) : "NULL");
+  fprintf_filtered (gdb_stdlog,
+		    "qf->find_pc_sect_compunit_symtab (...) = %s\n",
+		    retval
+		    ? debug_symtab_name (compunit_primary_filetab (retval))
+		    : "NULL");
 
   return retval;
 }
@@ -368,7 +374,7 @@ static const struct quick_symbol_functions debug_sym_quick_functions =
   debug_qf_expand_symtabs_with_fullname,
   debug_qf_map_matching_symbols,
   debug_qf_expand_symtabs_matching,
-  debug_qf_find_pc_sect_symtab,
+  debug_qf_find_pc_sect_compunit_symtab,
   debug_qf_map_symbol_filenames
 };
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 01ff6ae..29877ec 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2641,7 +2641,7 @@ reread_symbols (void)
 	  objfile->psymbol_cache = psymbol_bcache_init ();
 	  obstack_free (&objfile->objfile_obstack, 0);
 	  objfile->sections = NULL;
-	  objfile->symtabs = NULL;
+	  objfile->compunit_symtabs = NULL;
 	  objfile->psymtabs = NULL;
 	  objfile->psymtabs_addrmap = NULL;
 	  objfile->free_psymtabs = NULL;
@@ -2918,38 +2918,20 @@ deduce_language_from_filename (const char *filename)
   return language_unknown;
 }
 
-/* allocate_symtab:
-
-   Allocate and partly initialize a new symbol table.  Return a pointer
-   to it.  error() if no space.
-
-   Caller must set these fields:
-   LINETABLE(symtab)
-   symtab->blockvector
-   symtab->dirname
-   symtab->free_code
-   symtab->free_ptr
- */
+/* Allocate and initialize a new symbol table.
+   CUST is from the result of allocate_compunit_symtab.  */
 
 struct symtab *
-allocate_symtab (const char *filename, struct objfile *objfile)
+allocate_symtab (struct compunit_symtab *cust, const char *filename)
 {
-  struct symtab *symtab;
+  struct objfile *objfile = cust->objfile;
+  struct symtab *symtab
+    = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symtab);
 
-  symtab = (struct symtab *)
-    obstack_alloc (&objfile->objfile_obstack, sizeof (struct symtab));
-  memset (symtab, 0, sizeof (*symtab));
   symtab->filename = bcache (filename, strlen (filename) + 1,
 			     objfile->per_bfd->filename_cache);
   symtab->fullname = NULL;
   symtab->language = deduce_language_from_filename (filename);
-  symtab->debugformat = "unknown";
-
-  /* Hook it to the objfile it comes from.  */
-
-  SYMTAB_OBJFILE (symtab) = objfile;
-  symtab->next = objfile->symtabs;
-  objfile->symtabs = symtab;
 
   /* This can be very verbose with lots of headers.
      Only print at higher debug levels.  */
@@ -2973,7 +2955,64 @@ allocate_symtab (const char *filename, struct objfile *objfile)
 			  host_address_to_string (symtab), filename);
     }
 
-  return (symtab);
+  /* Add it to CUST's list of symtabs.  */
+  if (cust->filetabs == NULL)
+    {
+      cust->filetabs = symtab;
+      cust->last_filetab = symtab;
+    }
+  else
+    {
+      cust->last_filetab->next = symtab;
+      cust->last_filetab = symtab;
+    }
+
+  /* Backlink to the containing compunit symtab.  */
+  symtab->compunit_symtab = cust;
+
+  return symtab;
+}
+
+/* Allocate and initialize a new compunit.
+   NAME is the name of the main source file, if there is one, or some
+   descriptive text if there are no source files.  */
+
+struct compunit_symtab *
+allocate_compunit_symtab (struct objfile *objfile, const char *name)
+{
+  struct compunit_symtab *cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+					       struct compunit_symtab);
+  const char *saved_name;
+
+  cu->objfile = objfile;
+
+  /* The name we record here is only for display/debugging purposes.
+     Just save the basename to avoid path issues (too long for display,
+     relative vs absolute, etc.).  */
+  saved_name = lbasename (name);
+  cu->name = obstack_copy0 (&objfile->objfile_obstack, saved_name,
+			    strlen (saved_name));
+
+  COMPUNIT_DEBUGFORMAT (cu) = "unknown";
+
+  if (symtab_create_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "Created compunit symtab %s for %s.\n",
+			  host_address_to_string (cu),
+			  cu->name);
+    }
+
+  return cu;
+}
+
+/* Hook CU to the objfile it comes from.  */
+
+void
+add_compunit_symtab_to_objfile (struct compunit_symtab *cu)
+{
+  cu->next = cu->objfile->compunit_symtabs;
+  cu->objfile->compunit_symtabs = cu;
 }
 
 
diff --git a/gdb/symfile.h b/gdb/symfile.h
index f56aff3..1e8c230 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -193,13 +193,13 @@ struct quick_symbol_functions
      symbols.  NAME is the name of the symbol to look for.  DOMAIN
      indicates what sort of symbol to search for.
 
-     Returns the newly-expanded symbol table in which the symbol is
+     Returns the newly-expanded compunit in which the symbol is
      defined, or NULL if no such symbol table exists.  If OBJFILE
-     contains !TYPE_OPAQUE symbol prefer its symtab.  If it contains
-     only TYPE_OPAQUE symbol(s), return at least that symtab.  */
-  struct symtab *(*lookup_symbol) (struct objfile *objfile,
-				   int block_index, const char *name,
-				   domain_enum domain);
+     contains !TYPE_OPAQUE symbol prefer its compunit.  If it contains
+     only TYPE_OPAQUE symbol(s), return at least that compunit.  */
+  struct compunit_symtab *(*lookup_symbol) (struct objfile *objfile,
+					    int block_index, const char *name,
+					    domain_enum domain);
 
   /* Print statistics about any indices loaded for OBJFILE.  The
      statistics should be printed to gdb_stdout.  This is used for
@@ -285,17 +285,15 @@ struct quick_symbol_functions
      enum search_domain kind,
      void *data);
 
-  /* Return the symbol table from OBJFILE that contains PC and
-     SECTION.  Return NULL if there is no such symbol table.  This
-     should return the symbol table that contains a symbol whose
+  /* Return the comp unit from OBJFILE that contains PC and
+     SECTION.  Return NULL if there is no such compunit.  This
+     should return the compunit that contains a symbol whose
      address exactly matches PC, or, if there is no exact match, the
-     symbol table that contains a symbol whose address is closest to
+     compunit that contains a symbol whose address is closest to
      PC.  */
-  struct symtab *(*find_pc_sect_symtab) (struct objfile *objfile,
-					 struct bound_minimal_symbol msymbol,
-					 CORE_ADDR pc,
-					 struct obj_section *section,
-					 int warn_if_readin);
+  struct compunit_symtab *(*find_pc_sect_compunit_symtab)
+    (struct objfile *objfile, struct bound_minimal_symbol msymbol,
+     CORE_ADDR pc, struct obj_section *section, int warn_if_readin);
 
   /* Call a callback for every file defined in OBJFILE whose symtab is
      not already read in.  FUN is the callback.  It is passed the file's
@@ -418,9 +416,15 @@ extern struct symfile_segment_data *default_symfile_segments (bfd *abfd);
 extern bfd_byte *default_symfile_relocate (struct objfile *objfile,
                                            asection *sectp, bfd_byte *buf);
 
-extern struct symtab *allocate_symtab (const char *, struct objfile *)
+extern struct symtab *allocate_symtab (struct compunit_symtab *, const char *)
   ATTRIBUTE_NONNULL (1);
 
+extern struct compunit_symtab *allocate_compunit_symtab (struct objfile *,
+							 const char *)
+  ATTRIBUTE_NONNULL (1);
+
+extern void add_compunit_symtab_to_objfile (struct compunit_symtab *cu);
+
 extern void add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *);
 
 /* This enum encodes bit-flags passed as ADD_FLAGS parameter to
