Re: [PATCH v4 46/58] objtool/klp: Add test for data object checksums
From: Song Liu <song@kernel.org>
Date: 2026-09-16 07:00:33
Also in:
sashiko-reviews
On Tue, Sep 15, 2026 at 4:53 PM [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] objtool/klp: test-checksum-data fails on GCC < 10 due to missing -fno-common -- commit 1954bfc131a001b6d52e72e9ea82e16372d49e2b Author: Song Liu [off-list ref] objtool/klp: Add test for data object checksums This commit adds a test suite for data object checksum calculations in objtool's klp functionality. It verifies that various changes to data objects, such as length, bytes, reloc targets, and string contents, correctly update the objtool klp checksum.quoted
diff --git a/tools/objtool/tests/generic/fixtures/checksum_data.c b/tools/objtool/tests/generic/fixtures/checksum_data.c new file mode 100644 index 0000000000000..6310af5c02d34 --- /dev/null +++ b/tools/objtool/tests/generic/fixtures/checksum_data.c[ ... ]quoted
+/* + * A .bss object, where length is the only thing there is to hash: the section + * has no data, so the bytes are skipped and only sym->len distinguishes this + * from an object of another size. An initialised array would not isolate it + * -- growing one changes the hashed bytes as well. + */ +#if defined(PATCHED) && defined(LONGER) +char sized[4]; +#else +char sized[2]; +#endif[Severity: Low] Will this test fail on older toolchains (like GCC < 10 or Clang < 11) where -fcommon is the default? Because sized is an uninitialized array, these older compilers emit it as a SHN_COMMON symbol. objtool klp checksum skips SHN_COMMON symbols because they lack a data section pointer (!sym->sec->data), meaning no checksum is calculated for sized. This would cause the test script to abort. Could we add -fno-common to the test's FIXTURE_CFLAGS, or initialize this array to ensure it lands in .bss instead of COMMON?quoted
+ +/*[ ... ]quoted
diff --git a/tools/objtool/tests/generic/test-checksum-data.sh b/tools/objtool/tests/generic/test-checksum-data.sh new file mode 100755 index 0000000000000..e915026b79a73 --- /dev/null +++ b/tools/objtool/tests/generic/test-checksum-data.sh[ ... ]quoted
+# The object's own bytes. +check PLAIN_VALUE plain +# Its length, for a .bss object whose bytes are not hashed at all. +check LONGER sized[Severity: Low] Could this check fail with "no checksum recorded for 'sized'" on compilers defaulting to -fcommon due to the SHN_COMMON behavior mentioned above?
Added -fno-commont to 05/58 of v5. Thanks, Song