+ Temp fix for http://sourceware.org/bugzilla/show_bug.cgi?id=14704
+ * bfd/elf.c (bfd_section_from_shdr, case SHT_REL,SHT_RELA): Don't mark
+ the target section as having relocs if the reloc section is empty.
+--- README.google 2015-09-05 15:24:02.000000000 -0700
++++ README.google 2015-09-05 16:13:49.000000000 -0700
++
++2015-09-05 Doug Evans <dje@google.com>
++
++ Quick hack to workaround bfd memory wastage, bug 8033013.
++ Upstream: http://sourceware.org/bugzilla/show_bug.cgi?id=14108
++ * bfd/bfd-in.h (bfd_init_14108, bfd_release_14108): Declare.
++ * bfd/bfd-in2.h: Regenerate.
++ * bfd/bfd.c (struct bfd): New members use_14108, memory_14108.
++ * bfd/elfcode.h (elf_slurp_symbol_table): If user requested, allocate
++ space for symbols in memory_14108.
++ * bfd/opncls.c (_bfd_delete_bfd): Free memory_14108.
++ (_bfd_free_cached_info): Ditto.
++ (bfd_init_14108, bfd_release_14108): New functions.
++ (bfd_alloc_aux, bfd_release_all_aux): New functions.
++ * gdb/elfread.c (elf_symfile_read): Free memory for normal symtab.
++ * gdb/solib.c (gdb_bfd_lookup_symbol_from_symtab): Ditto.
extern bfd_boolean _bfd_handle_already_linked
(struct bfd_section *, struct bfd_section_already_linked *,
struct bfd_link_info *);
+
+/* GOOGLE LOCAL 14108 */
+extern void bfd_init_14108 (bfd *);
+extern void *bfd_release_14108 (bfd *);
+/* END GOOGLE LOCAL */
\f
/* Externally visible ECOFF routines. */
extern bfd_boolean _bfd_handle_already_linked
(struct bfd_section *, struct bfd_section_already_linked *,
struct bfd_link_info *);
+
+/* GOOGLE LOCAL 14108 */
+extern void bfd_init_14108 (bfd *);
+extern void *bfd_release_14108 (bfd *);
+/* END GOOGLE LOCAL */
\f
/* Externally visible ECOFF routines. */
of objalloc.h. */
void *memory;
+ /* GOOGLE LOCAL 14108
+ For large apps, gdb can waste >= 450MB of space.
+ http://sourceware.org/bugzilla/show_bug.cgi?id=14108
+ Record the space used here, so it can be individually freed.
+ This is just a quick hack until The Right Thing is implemented. */
+ int use_14108;
+ void *memory_14108;
+ /* END GOOGLE LOCAL */
+
/* For input BFDs, the build ID, if the object has one. */
const struct bfd_build_id *build_id;
};
. of objalloc.h. *}
. void *memory;
.
+. {* GOOGLE LOCAL 14108
+. For large apps, gdb can waste >= 450MB of space.
+. http://sourceware.org/bugzilla/show_bug.cgi?id=14108
+. Record the space used here, so it can be individually freed.
+. This is just a quick hack until The Right Thing is implemented. *}
+. int use_14108;
+. void *memory_14108;
+. {* END GOOGLE LOCAL *}
+.
. {* For input BFDs, the build ID, if the object has one. *}
. const struct bfd_build_id *build_id;
.};
amt = symcount;
amt *= sizeof (elf_symbol_type);
- symbase = (elf_symbol_type *) bfd_zalloc (abfd, amt);
+ /* GOOGLE LOCAL 14108 */
+ if (abfd->use_14108)
+ {
+ symbase = (elf_symbol_type *) bfd_zmalloc (amt);
+ abfd->memory_14108 = symbase;
+ }
+ else
+ {
+ symbase = (elf_symbol_type *) bfd_zalloc (abfd, amt);
+ }
+ /* END GOOGLE LOCAL */
if (symbase == (elf_symbol_type *) NULL)
goto error_return;
bfd_hash_table_free (&abfd->section_htab);
objalloc_free ((struct objalloc *) abfd->memory);
}
+ /* GOOGLE LOCAL 14108 */
+ free (abfd->memory_14108);
+ /* END GOOGLE LOCAL */
if (abfd->filename)
free ((char *) abfd->filename);
{
bfd_hash_table_free (&abfd->section_htab);
objalloc_free ((struct objalloc *) abfd->memory);
+ /* GOOGLE LOCAL 14108 */
+ free (abfd->memory_14108);
+ abfd->memory_14108 = NULL;
+ abfd->use_14108 = FALSE;
+ /* END GOOGLE LOCAL */
abfd->sections = NULL;
abfd->section_last = NULL;
return ret;
}
+/* GOOGLE LOCAL 14108 */
+
+void
+bfd_init_14108 (bfd *abfd)
+{
+ abfd->use_14108 = TRUE;
+}
+
+void *
+bfd_release_14108 (bfd *abfd)
+{
+ void *result = abfd->memory_14108;
+
+ abfd->use_14108 = FALSE;
+ abfd->memory_14108 = NULL;
+ return result;
+}
+
+/* END GOOGLE LOCAL */
+
/*
INTERNAL_FUNCTION
bfd_alloc2
bfd_canonicalize_symtab so it must not get freed before ABFD gets. */
symbol_table = bfd_alloc (abfd, storage_needed);
+ /* GOOGLE LOCAL 14108 */
+ bfd_init_14108 (objfile->obfd);
symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
+ make_cleanup (xfree, bfd_release_14108 (objfile->obfd));
+ /* END GOOGLE LOCAL */
if (symcount < 0)
error (_("Can't read symbols from %s: %s"),
asymbol **symbol_table = (asymbol **) xmalloc (storage_needed);
struct cleanup *back_to = make_cleanup (xfree, symbol_table);
- unsigned int number_of_symbols =
- bfd_canonicalize_symtab (abfd, symbol_table);
+ /* GOOGLE LOCAL 14108 */
+ unsigned int number_of_symbols;
+
+ bfd_init_14108 (abfd);
+ number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
+ make_cleanup (xfree, bfd_release_14108 (abfd));
+ /* END GOOGLE LOCAL */
for (i = 0; i < number_of_symbols; i++)
{