Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool/klp: Remove trailing '_' in demangle_name()

With CONFIG_LTO_CLANG_THIN, it is possible to have nested __UNIQUE_ID_,
such as:

__UNIQUE_ID_addressable___UNIQUE_ID_pci_invalid_bar_694_695

To remove both trailing numbers, also remove trailing '_'.

Also add comments to demangle_name().

Signed-off-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/20260305231531.3847295-3-song@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

authored by

Song Liu and committed by
Josh Poimboeuf
a3f28d20 a1cbaff2

+14 -1
+14 -1
tools/objtool/elf.c
··· 441 441 return 0; 442 442 } 443 443 444 + /* 445 + * Remove number suffix of a symbol. 446 + * 447 + * Specifically, remove trailing numbers for "__UNIQUE_ID_" symbols and 448 + * symbols with '.'. 449 + * 450 + * With CONFIG_LTO_CLANG_THIN, it is possible to have nested __UNIQUE_ID_, 451 + * such as 452 + * 453 + * __UNIQUE_ID_addressable___UNIQUE_ID_pci_invalid_bar_694_695 454 + * 455 + * to remove both trailing numbers, also remove trailing '_'. 456 + */ 444 457 static const char *demangle_name(struct symbol *sym) 445 458 { 446 459 char *str; ··· 476 463 for (int i = strlen(str) - 1; i >= 0; i--) { 477 464 char c = str[i]; 478 465 479 - if (!isdigit(c) && c != '.') { 466 + if (!isdigit(c) && c != '.' && c != '_') { 480 467 str[i + 1] = '\0'; 481 468 break; 482 469 }