mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
klp diff names the intermediate __klp_relocs section after the object the
relocation belongs to, and post-link turns that into
.klp.rela.<object>.<sec>. Name it after the wrong object and the kernel
applies the relocation when the wrong module loads, or never.
The fixture is the first here to honour MODNAME: most hardcode
name=vmlinux, so passing -DMODNAME to them silently does nothing and the
test quietly becomes a vmlinux test.
This tests the behavior of commit 07f14d6af9 ("objtool/klp: Fix
cross-module klp relocation section naming").
Assisted-by: Claude:claude-opus-4
Based-on-test-by: Joe Lawrence <[email protected]>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <[email protected]>
Signed-off-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Link: https://patch.msgid.link/[email protected]
32 lines
1.0 KiB
Bash
Executable File
32 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# A klp relocation section is named for the object being patched, not for the
|
|
# object which happens to own the symbol being referenced. Deriving it from
|
|
# the symbol means a cross-module reference lands in a section for an object
|
|
# the patch may not even touch, so the relocation is never applied and the call
|
|
# goes somewhere arbitrary.
|
|
|
|
. "$(dirname "$0")/../lib.sh"
|
|
|
|
setup
|
|
build_module_pair cross_module.c klp_testmod
|
|
|
|
# The fixture has to have built as a module for any of this to mean anything.
|
|
in_sections orig.o | grep -q '\.modinfo' ||
|
|
fail "fixture has no .modinfo"
|
|
|
|
# other_mod_func belongs to a different module than the one being patched.
|
|
add_exports other_mod other_mod_func
|
|
run_diff
|
|
|
|
# Named for the patched object ...
|
|
assert_section __klp_relocs.klp_testmod
|
|
# ... not for the object owning the symbol.
|
|
assert_no_section __klp_relocs.other_mod
|
|
|
|
run_post_link
|
|
assert_klp_rela klp_testmod .text.target
|
|
|
|
pass "klp relocation section named for the patched object"
|