question about elf_slurp_symbol_table
Tom Tromey
tom@tromey.com
Tue Mar 4 14:21:10 GMT 2025
For background, see
https://sourceware.org/bugzilla/show_bug.cgi?id=32758, a case where gdb
uses a lot of memory when printing some section info.
Following the thread from massif, I found this code in
elf_slurp_symbol_table:
symbase = (elf_symbol_type *) bfd_zalloc (abfd, amt);
This line is the immediate cause of the memory use in that bug.
It would be better, IMO, if either these symbols were cached and then
just reused on subsequent calls; or if this memory were freed before
returning. However, I wasn't sure if there was some reason for the
current approach.
You could write a more "pure BFD" reproducer by just calling
bfd_canonicalize_symtab 10000 times in a loop.
thanks,
Tom
More information about the Binutils
mailing list