This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

memory usage with large debug sections


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]