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