]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool/klp: Remove trailing '_' in demangle_name()
authorSong Liu <song@kernel.org>
Thu, 5 Mar 2026 23:15:26 +0000 (15:15 -0800)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Fri, 6 Mar 2026 16:08:30 +0000 (08:08 -0800)
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>
tools/objtool/elf.c

index a634b227d62725b256f71bb7c75410e5e062a5c2..fe6e66dd5422789e2629a6c40737b78dec25365e 100644 (file)
@@ -441,6 +441,19 @@ static int read_sections(struct elf *elf)
        return 0;
 }
 
+/*
+ * Remove number suffix of a symbol.
+ *
+ * Specifically, remove trailing numbers for "__UNIQUE_ID_" symbols and
+ * symbols with '.'.
+ *
+ * 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 '_'.
+ */
 static const char *demangle_name(struct symbol *sym)
 {
        char *str;
@@ -463,7 +476,7 @@ static const char *demangle_name(struct symbol *sym)
        for (int i = strlen(str) - 1; i >= 0; i--) {
                char c = str[i];
 
-               if (!isdigit(c) && c != '.') {
+               if (!isdigit(c) && c != '.' && c != '_') {
                        str[i + 1] = '\0';
                        break;
                }