diff --git a/tools/objtool/klp-checksum.c b/tools/objtool/klp-checksum.c
index 1a5f2fa89baa..44c0eb784e57 100644
--- a/tools/objtool/klp-checksum.c
+++ b/tools/objtool/klp-checksum.c
@@ -77,6 +77,12 @@ static bool is_const_reference(struct symbol *sym)
static int checksum_object(struct objtool_file *file, struct symbol *sym,
unsigned int depth);
+/* Use suffix-stripped ELF names for references without DWARF identities. */
+static const char *checksum_name(struct symbol *sym)
+{
+ return sym->identity.path ?: sym->identity.demangled_name;
+}
+
static int checksum_update_insn(struct objtool_file *file, struct symbol *func,
struct instruction *insn)
{@@ -110,8 +116,8 @@ static int checksum_update_insn(struct objtool_file *file, struct symbol *func,
__checksum_update_insn(func, insn, buf, len);
if (call_dest) {
- __checksum_update_insn(func, insn, call_dest->identity.demangled_name,
- strlen(call_dest->identity.demangled_name));
+ __checksum_update_insn(func, insn, checksum_name(call_dest),
+ strlen(checksum_name(call_dest)));
} else if (jump_dest) {
struct symbol *dest_sym;@@ -127,8 +133,8 @@ static int checksum_update_insn(struct objtool_file *file, struct symbol *func,
if (!dest_sym)
goto alts;
- __checksum_update_insn(func, insn, dest_sym->identity.demangled_name,
- strlen(dest_sym->identity.demangled_name));
+ __checksum_update_insn(func, insn, checksum_name(dest_sym),
+ strlen(checksum_name(dest_sym)));
offset = jump_dest->offset - dest_sym->offset;
__checksum_update_insn(func, insn, &offset, sizeof(offset));
@@ -170,8 +176,8 @@ static int checksum_update_insn(struct objtool_file *file, struct symbol *func,
__checksum_update_insn(func, insn, &sym->csum.checksum,
sizeof(sym->csum.checksum));
} else {
- __checksum_update_insn(func, insn, sym->identity.demangled_name,
- strlen(sym->identity.demangled_name));
+ __checksum_update_insn(func, insn, checksum_name(sym),
+ strlen(checksum_name(sym)));
}
__checksum_update_insn(func, insn, &offset, sizeof(offset));
@@ -265,9 +271,9 @@ static int checksum_update_object(struct objtool_file *file, struct symbol *sym,
&target->csum.checksum,
sizeof(target->csum.checksum));
} else {
- __checksum_update_object(sym, sym_offset, "reloc name",
- target->identity.demangled_name,
- strlen(target->identity.demangled_name));
+ __checksum_update_object(sym, sym_offset, "reloc identity",
+ checksum_name(target),
+ strlen(checksum_name(target)));
}
__checksum_update_object(sym, sym_offset, "reloc addend",
&offset, sizeof(offset));@@ -387,6 +393,7 @@ static const char * const klp_checksum_usage[] = {
int cmd_klp_checksum(int argc, const char **argv)
{
struct objtool_file *file;
+ struct symbol *sym;
int ret;
const struct option options[] = {@@ -411,6 +418,12 @@ int cmd_klp_checksum(int argc, const char **argv)
if (ret)
goto out;
+ for_each_sym(file->elf, sym)
+ sym->dont_correlate = dont_correlate(sym);
+ ret = prepare_identities(file->elf);
+ if (ret)
+ goto out;
+
ret = calculate_checksums(file);
if (ret)
goto out;
--
2.55.0