projects/linux·blob master · refs

25 lines · 585 B

1// SPDX-License-Identifier: GPL-2.0
2/*
3 * A function which calls out to another object. MODNAME selects which object
4 * this one is, so a test can make the caller a module and the callee's owner
5 * something else.
6 */
7
8#ifndef MODNAME
9#define MODNAME "vmlinux"
10#endif
11
12/* klp diff takes the object's module name from .modinfo */
13static const char __modinfo[]
14 __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=" MODNAME;
15
16extern int other_mod_func(int x);
17
18int target(int x)
19{
20#ifdef PATCHED
21 return other_mod_func(x) + 2;
22#else
23 return other_mod_func(x) + 1;
24#endif
25}