objtool: Allocate multiple structures with calloc()
authorThomas Weißschuh <linux@weissschuh.net>
Tue, 27 Dec 2022 16:00:59 +0000 (16:00 +0000)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 1 Feb 2023 17:15:23 +0000 (09:15 -0800)
commit8045b8f0b17edf375849f83c80dd05194850b6ed
tree24aa73268610f0191db29d47503f49490824edca
parentcfd66e81799f4a2fdc6447fa99bdb1871f45ff08
objtool: Allocate multiple structures with calloc()

By using calloc() instead of malloc() in a loop, libc does not have to
keep around bookkeeping information for each single structure.

This reduces maximum memory usage while processing vmlinux.o from
3153325 KB to 3035668 KB (-3.7%) on my notebooks "localmodconfig".

Note this introduces memory leaks, because some additional structs get
added to the lists later after reading the symbols and sections from the
original object.  Luckily we don't really care about memory leaks in
objtool.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20221216-objtool-memory-v2-3-17968f85a464@weissschuh.net
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/elf.c
tools/objtool/include/objtool/elf.h