This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: binutils/2467: "ar q" / ranlib has large memory use (linear in archive size)
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Cc: dcoutts at gentoo dot org
- Date: Mon, 20 Mar 2006 18:23:03 -0800
- Subject: PATCH: binutils/2467: "ar q" / ranlib has large memory use (linear in archive size)
Do we need the objalloc memory for the archive members after
_bfd_compute_and_write_armap is called? If not, we should be able
to free all the objalloc memory in _bfd_generic_bfd_free_cached_info.
Will this patch break anything?
H.J.
---
2006-03-21 Duncan Coutts <dcoutts@gentoo.org>
H.J. Lu <hongjiu.lu@intel.com>
PR binutils/2467
* libbfd-in.h (_bfd_generic_bfd_free_cached_info): Make it a
function prototype.
* libbfd: Regenerated.
* opncls.c (_bfd_generic_bfd_free_cached_info): New.
--- bfd/libbfd-in.h.cached 2006-03-16 12:37:43.000000000 -0800
+++ bfd/libbfd-in.h 2006-03-20 18:07:14.000000000 -0800
@@ -155,6 +155,8 @@ bfd * _bfd_new_bfd
(void);
void _bfd_delete_bfd
(bfd *);
+bfd_boolean _bfd_generic_bfd_free_cached_info
+ (bfd *);
bfd_boolean bfd_false
(bfd *ignore);
@@ -214,7 +216,6 @@ int bfd_generic_stat_arch_elt
BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
#define _bfd_generic_close_and_cleanup bfd_true
-#define _bfd_generic_bfd_free_cached_info bfd_true
#define _bfd_generic_new_section_hook \
((bfd_boolean (*) (bfd *, asection *)) bfd_true)
extern bfd_boolean _bfd_generic_get_section_contents
--- bfd/opncls.c.cached 2006-03-16 12:37:43.000000000 -0800
+++ bfd/opncls.c 2006-03-20 18:11:54.000000000 -0800
@@ -120,6 +120,24 @@ _bfd_delete_bfd (bfd *abfd)
free (abfd);
}
+/* Free objalloc memory. */
+
+bfd_boolean
+_bfd_generic_bfd_free_cached_info (bfd *abfd)
+{
+ bfd_hash_table_free (&abfd->section_htab);
+ objalloc_free ((struct objalloc *) abfd->memory);
+
+ abfd->sections = NULL;
+ abfd->section_last = NULL;
+ abfd->outsymbols = NULL;
+ abfd->tdata.any = NULL;
+ abfd->usrdata = NULL;
+ abfd->memory = NULL;
+
+ return TRUE;
+}
+
/*
SECTION
Opening and closing BFDs