]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
patch ../102426802.patch
authorDoug Evans <dje@google.com>
Thu, 10 Dec 2015 20:00:29 +0000 (12:00 -0800)
committerDoug Evans <dje@google.com>
Thu, 10 Dec 2015 20:00:29 +0000 (12:00 -0800)
README.google
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c
bfd/elfcode.h
bfd/opncls.c
gdb/elfread.c
gdb/solib.c

index 355d20c271d0b5a63b97ebd6c3d2d1355a0e06e7..e197a5975e044fb48434b72069fae027179eb4bd 100644 (file)
@@ -76,3 +76,21 @@ they are an ongoing maintenance burden.
 +      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.
index ae99d1e356118d46655c6d8284e4a9b1c294e77d..3146ce53ff9f24922f93ccebd0e07d814da143f4 100644 (file)
@@ -579,6 +579,11 @@ extern void bfd_section_already_linked_table_free (void);
 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.  */
 
index 85f2054ba5816fc31fbb3f9bf768aeebc68299d8..ee5ca09a07d60ffe30a3f991fb4ed81adda50806 100644 (file)
@@ -586,6 +586,11 @@ extern void bfd_section_already_linked_table_free (void);
 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.  */
 
@@ -6632,6 +6637,15 @@ struct bfd
      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;
 };
index 8d85de50b970580cc093bca7f884dd7e42ba2271..dde96f242c1fbca7cfef84c5cb7362467827291c 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -342,6 +342,15 @@ CODE_FRAGMENT
 .     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;
 .};
index 7e309cf998e004f189da19679e092248469b52f4..679a0d0e949059a3debf2c59ab0a3f9e33d1982c 100644 (file)
@@ -1174,7 +1174,17 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
 
       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;
 
index f0f2e64b319a5fafbbef48ef8e6a2d856705c6c5..d07b473a17ff317a5480e41421b449e1fcab0488 100644 (file)
@@ -124,6 +124,9 @@ _bfd_delete_bfd (bfd *abfd)
       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);
@@ -140,6 +143,11 @@ _bfd_free_cached_info (bfd *abfd)
     {
       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;
@@ -961,6 +969,26 @@ bfd_alloc (bfd *abfd, bfd_size_type size)
   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
index 0e169c7c8ca89098f376c805646ecc3e5ebdb034..b3e7a138b453e2821b3d3fb44023474981d59746 100644 (file)
@@ -1057,7 +1057,11 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
         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"),
index eb933c044d55b99f6042ff88ec4eca0ce9d6bf30..97475075cd258ac24747087b8f5bad8d03f29eae 100644 (file)
@@ -1542,8 +1542,13 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd,
 
       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++)
        {