Thread (88 messages) 88 messages, 2 authors, 2d ago

Re: [PATCH v2 47/58] objtool/klp: Add test for symbols with no checksum entry of their own

From: Song Liu <song@kernel.org>
Date: 2026-09-14 22:08:56
Also in: sashiko-reviews

On Sun, Sep 13, 2026 at 11:48 PM [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The generic check for duplicate addresses in the test script uses symbol names instead of actual addresses (symbol value + addend).
--

commit 8da269007d7ca99a4b81784ec070f665fec2ad95
Author: Song Liu [off-list ref]

objtool/klp: Add test for symbols with no checksum entry of their own

This commit adds a test script and a C fixture to verify that objtool
correctly skips checksum entries for zero-length, alias, and cold-part
symbols. It ensures that the invariant of one entry per address in
.discard.sym_checksum is maintained.
quoted
diff --git a/tools/objtool/tests/generic/test-checksum-skip.sh b/tools/objtool/tests/generic/test-checksum-skip.sh
new file mode 100755
index 0000000000000..6e3e7055d31c3
--- /dev/null
+++ b/tools/objtool/tests/generic/test-checksum-skip.sh
@@ -0,0 +1,72 @@
[ ... ]
quoted
+
+# entries_for <object>
+#
+# The symbol names .discard.sym_checksum has an entry for, one per line.
+entries_for()
+{
+     in_relocs "$1" | awk '/rela\.discard\.sym_checksum/,/^$/ {
+             if ($1 ~ /^[0-9a-f]{8,}/) print $5
+     }'
+}
+
+entries="$(entries_for orig.o)"
+
[ ... ]
quoted
+
+# One entry per address, which is what the skipping is for.
+dupes="$(entries_for orig.o | sort | uniq -d)"
+[ -z "$dupes" ] ||
+     fail "two checksum entries for one address: $dupes"
[Severity: Low]
Does this generic uniqueness check correctly identify duplicate addresses?

Since entries_for() extracts only the symbol name (column 5 of the readelf
output), this check doesn't seem to evaluate the actual resolved address
(symbol value + addend).

Wouldn't it fail to detect two different symbols mapping to the same address,
or potentially fail spuriously if multiple static functions share a section
symbol with different addends?

Since this is a test script with a tightly controlled C fixture (without
static functions) and the alias case is explicitly tested beforehand, it
doesn't break this specific test case. However, should the check be updated
to use actual resolved addresses instead of just symbol names?
Fixed this by adding an argument for entries_for().

Thanks,
Song
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help