objtool: Speed up SHT_GROUP reindexing
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 7 May 2025 23:56:55 +0000 (16:56 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 14 May 2025 11:09:02 +0000 (13:09 +0200)
commit4ed9d82bf5b21d65e2f18249eec89a6a84df8f23
treefe4280c54b29644b7860378b5857fb65880c8dcf
parent2cb291596e2c1837238bc322ae3545dacb99d584
objtool: Speed up SHT_GROUP reindexing

After elf_update_group_sh_info() was introduced, a prototype version of
"objtool klp diff" went from taking ~1s to several minutes, due to
looping almost endlessly in elf_update_group_sh_info() while creating
thousands of local symbols in a file with thousands of sections.

Dramatically improve the performance by marking all symbols' correlated
SHT_GROUP sections while reading the object.  That way there's no need
to search for it every time a symbol gets reindexed.

Fixes: 2cb291596e2c ("objtool: Fix up st_info in COMDAT group section")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Rong Xu <xur@google.com>
Link: https://lkml.kernel.org/r/2a33e583c87e3283706f346f9d59aac20653b7fd.1746662991.git.jpoimboe@kernel.org
tools/objtool/elf.c
tools/objtool/include/objtool/elf.h