xref: /linux/tools/objtool/tests/x86/fixtures/static_call_no_key.c (revision 5b6dca02b3e2254d2fd5706d76d7ab4610a67296)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * A static call to a trampoline whose key symbol this object cannot see.
4  *
5  * That is the normal situation for a module: __SCK__* keys are not exported,
6  * and read-only access is granted at load time instead.  objtool's static call
7  * handling has to accept it for any module, including a livepatch module built
8  * by hand rather than by klp-build.
9  *
10  * LIVEPATCH adds the .modinfo tag which makes objtool treat this as a
11  * livepatch module.
12  */
13 
14 static const char __modinfo[]
15 	__attribute__((section(".modinfo"), used, aligned(1))) =
16 #ifdef LIVEPATCH
17 	"\0livepatch=Y"
18 #endif
19 	"\0name=klp_testmod";
20 
21 /*
22  * The trampoline is undefined here, exactly as it is for a module calling a
23  * static call defined in vmlinux.  No __SCK__klp_test_call accompanies it.
24  */
25 extern void __SCT__klp_test_call(void);
26 
target(int x)27 int target(int x)
28 {
29 	__asm__ volatile("call __SCT__klp_test_call\n\t" ::: "memory");
30 
31 	return x + 1;
32 }
33