diff options
author | Doug Evans <dje@google.com> | 2015-12-10 12:00:29 -0800 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2015-12-10 12:00:29 -0800 |
commit | ec5063d304949040e577d0378bc4d8c5ca65790b (patch) | |
tree | 3bb97cec9185a6c03b90cb2febee0eaa3cf67f96 | |
parent | 2504c7b071262e2ee2a2e331f4550eabc7e25520 (diff) | |
download | fsf-binutils-gdb-ec5063d304949040e577d0378bc4d8c5ca65790b.zip fsf-binutils-gdb-ec5063d304949040e577d0378bc4d8c5ca65790b.tar.gz fsf-binutils-gdb-ec5063d304949040e577d0378bc4d8c5ca65790b.tar.bz2 |
patch ../102426802.patch
-rw-r--r-- | README.google | 18 | ||||
-rw-r--r-- | bfd/bfd-in.h | 5 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 14 | ||||
-rw-r--r-- | bfd/bfd.c | 9 | ||||
-rw-r--r-- | bfd/elfcode.h | 12 | ||||
-rw-r--r-- | bfd/opncls.c | 28 | ||||
-rw-r--r-- | gdb/elfread.c | 4 | ||||
-rw-r--r-- | gdb/solib.c | 9 |
8 files changed, 96 insertions, 3 deletions
diff --git a/README.google b/README.google index 355d20c..e197a59 100644 --- a/README.google +++ b/README.google @@ -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. diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index ae99d1e..3146ce5 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -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 */ /* Externally visible ECOFF routines. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 85f2054..ee5ca09 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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 */ /* 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; }; @@ -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; .}; diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 7e309cf..679a0d0 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -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; diff --git a/bfd/opncls.c b/bfd/opncls.c index f0f2e64..d07b473 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -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 diff --git a/gdb/elfread.c b/gdb/elfread.c index 0e169c7..b3e7a13 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -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"), diff --git a/gdb/solib.c b/gdb/solib.c index eb933c0..9747507 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -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++) { |