diff options
| author | Puranjay Mohan <puranjay@kernel.org> | 2026-09-16 11:43:16 -0700 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2026-09-21 11:05:20 +0200 |
| commit | d6f2548ec3508fac9ad0f2a7d6f4783f9f9cd119 (patch) | |
| tree | c68da1f373d8e343980e6f5a4252db46e3fc09c6 /tools/objtool/tests/generic/fixtures | |
| parent | e018004ab8fa4c68155da976125ed8645c075383 (diff) | |
objtool/klp: Add test for rejecting references to init code/data
Init code and data are freed once boot finishes, so a klp relocation
against them can never resolve.
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Assisted-by: Claude:claude-opus-5
Link: https://patch.msgid.link/20260916184351.2720310-24-song@kernel.org
Diffstat (limited to 'tools/objtool/tests/generic/fixtures')
| -rw-r--r-- | tools/objtool/tests/generic/fixtures/init_reference.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/objtool/tests/generic/fixtures/init_reference.c b/tools/objtool/tests/generic/fixtures/init_reference.c new file mode 100644 index 000000000000..9e59bdf708d3 --- /dev/null +++ b/tools/objtool/tests/generic/fixtures/init_reference.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Patched function referencing data in an .init section. */ + +static const char __modinfo[] + __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux"; + +/* volatile so the read cannot be folded into a constant, leaving no reference */ +static volatile int init_only __attribute__((section(".init.data"), used)) = 5; + +int target(int x) +{ +#ifdef PATCHED + return x + init_only + 1; +#else + return x + init_only; +#endif +} |
