xref: /linux/tools/objtool/tests/generic/fixtures/thinlto_local.c (revision 5b6dca02b3e2254d2fd5706d76d7ab4610a67296)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Two translation units (TU_B selects the second) linked with ThinLTO.
4  * Importing bump() promotes the file-local counter, renaming it
5  * counter.llvm.<hash>.  The hash is content derived, so it differs between the
6  * original and patched builds.
7  */
8 
9 #ifdef TU_B
10 
11 extern int bump(void);
12 
other_entry(void)13 int other_entry(void)
14 {
15 	return bump() + bump();
16 }
17 
18 #else
19 
20 static const char __modinfo[]
21 	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
22 
23 static int counter;
24 
bump(void)25 int bump(void)
26 {
27 	return ++counter;
28 }
29 
target(void)30 int target(void)
31 {
32 #ifdef PATCHED
33 	return counter + 1;
34 #else
35 	return counter;
36 #endif
37 }
38 
39 #endif
40