From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30626 invoked by alias); 5 Apr 2006 02:03:45 -0000 Received: (qmail 30615 invoked by uid 22791); 5 Apr 2006 02:03:45 -0000 X-Spam-Check-By: sourceware.org Received: from nat-198-95-226-231.netapp.com (HELO strangelet.hq.netapp.com) (198.95.226.231) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Apr 2006 02:03:44 +0000 Received: from strangelet.hq.netapp.com (nomura@strangelet.hq.netapp.com [127.0.0.1]) by strangelet.hq.netapp.com (8.13.2/8.13.2/Debian-1) with ESMTP id k3523hNj018600 for ; Tue, 4 Apr 2006 19:03:43 -0700 Received: (from nomura@localhost) by strangelet.hq.netapp.com (8.13.2/8.13.2/Submit) id k3523g3V018599 for binutils@sourceware.org; Tue, 4 Apr 2006 19:03:42 -0700 From: Kevin Nomura Date: Wed, 05 Apr 2006 02:03:00 -0000 To: binutils@sourceware.org Subject: memory usage with large debug sections Message-ID: <20060405020342.GG9379@netapp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00042.txt.bz2 Using 2.16.1. I have a partially linked object ('file1') with a debug section ~600MB in size, and am trying to reduce the memory taken by this: ld -Ur -o file2 file1 The debug section has the SEC_RELOC flag, so it causes 1.2 GB of malloc in bfd_elf_final_link() here: if (max_external_reloc_size != 0) { finfo.external_relocs = bfd_malloc (max_external_reloc_size); if (finfo.external_relocs == NULL) goto error_return; } if (max_internal_reloc_count != 0) { amt = max_internal_reloc_count * bed->s->int_rels_per_ext_rel; amt *= sizeof (Elf_Internal_Rela); finfo.internal_relocs = bfd_malloc (amt); if (finfo.internal_relocs == NULL) goto error_return; } These are where the sizes are set: if ((sec->flags & SEC_RELOC) != 0) { size_t ext_size; ext_size = elf_section_data (sec)->rel_hdr.sh_size; if (ext_size > max_external_reloc_size) max_external_reloc_size = ext_size; if (sec->reloc_count > max_internal_reloc_count) max_internal_reloc_count = sec->reloc_count; } Is it really the case that the size of a debug section has to be used to calculate the malloc size for these relocation structures? Kevin