objtool: Fix up st_info in COMDAT group section
authorRong Xu <xur@google.com>
Fri, 25 Apr 2025 20:05:41 +0000 (13:05 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 30 Apr 2025 11:58:34 +0000 (13:58 +0200)
commit2cb291596e2c1837238bc322ae3545dacb99d584
tree91b813f51f974fc511e3983e7b70d297c755656f
parentb4432656b36e5cc1d50a1f2dc15357543add530e
objtool: Fix up st_info in COMDAT group section

When __elf_create_symbol creates a local symbol, it relocates the first
global symbol upwards to make space. Subsequently, elf_update_symbol()
is called to refresh the symbol table section. However, this isn't
sufficient, as other sections might have the reference to the old
symbol index, for instance, the sh_info field of an SHT_GROUP section.

This patch updates the `sh_info` field when necessary. This field
serves as the key for the COMDAT group. An incorrect key would prevent
the linker's from deduplicating COMDAT symbols, leading to duplicate
definitions in the final link.

Signed-off-by: Rong Xu <xur@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250425200541.113015-1-xur@google.com
tools/objtool/elf.c