memory usage with large debug sections
Nick Clifton
nickc@redhat.com
Mon Apr 10 17:10:00 GMT 2006
Hi Kevin,
> 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?
No, but this size is guaranteed to be safe - there can never be more
relocs in a debug section than if the entire section held relocs and
nothing else.
If you would like to try to improve this code you could write a function
to count the number of relocs in the debug section and then use this
figure in the malloc.
Cheers
Nick
More information about the Binutils
mailing list