diff --git a/gdb/gdb_obstack.c b/gdb/gdb_obstack.c
index d8d03df..4cff52e 100644
--- a/gdb/gdb_obstack.c
+++ b/gdb/gdb_obstack.c
@@ -18,8 +18,30 @@
along with this program. If not, see . */
#include "defs.h"
+#include
#include "gdb_obstack.h"
+/* See gdb_obstack.h. */
+
+void
+gdb_obstack_init (struct obstack *obstack)
+{
+ struct find_alignment
+ {
+ char c;
+ union
+ {
+ ULONGEST i;
+ void *p;
+ } u;
+ };
+ int needed_alignment = offsetof (struct find_alignment, u);
+
+ obstack_specify_allocation (obstack, 0, needed_alignment,
+ /* Note: These are macros in gdb_obstack.h. */
+ obstack_chunk_alloc, obstack_chunk_free);
+}
+
/* Concatenate NULL terminated variable argument list of `const char *'
strings; return the new string. Space is found in the OBSTACKP.
Argument list must be terminated by a sentinel expression `(char *)
diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
index 3272721..518a593 100644
--- a/gdb/gdb_obstack.h
+++ b/gdb/gdb_obstack.h
@@ -22,6 +22,13 @@
#include "obstack.h"
+/* Initialize an obstack for gdb's use.
+ N.B. The alignment of the obstack is set for pointers and LONGEST,
+ but not long double. This saves 10s of megabytes when debugging large
+ programs. */
+
+extern void gdb_obstack_init (struct obstack *);
+
/* Utility macros - wrap obstack alloc into something more robust. */
#define OBSTACK_ZALLOC(OBSTACK,TYPE) \
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index f6be91e..4364247 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -147,7 +147,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
if (abfd != NULL)
storage->gdbarch = gdbarch_from_bfd (abfd);
- obstack_init (&storage->storage_obstack);
+ gdb_obstack_init (&storage->storage_obstack);
storage->filename_cache = bcache_xmalloc (NULL, NULL);
storage->macro_cache = bcache_xmalloc (NULL, NULL);
storage->language_of_main = language_unknown;
@@ -375,9 +375,7 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
objfile = XCNEW (struct objfile);
objfile->psymbol_cache = psymbol_bcache_init ();
- /* We could use obstack_specify_allocation here instead, but
- gdb_obstack.h specifies the alloc/dealloc functions. */
- obstack_init (&objfile->objfile_obstack);
+ gdb_obstack_init (&objfile->objfile_obstack);
objfile_alloc_data (objfile);