projects/linux·blob master · refs

39 lines · 651 B

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
11extern int bump(void);
12
13int other_entry(void)
14{
15 return bump() + bump();
16}
17
18#else
19
20static const char __modinfo[]
21 __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
22
23static int counter;
24
25int bump(void)
26{
27 return ++counter;
28}
29
30int target(void)
31{
32#ifdef PATCHED
33 return counter + 1;
34#else
35 return counter;
36#endif
37}
38
39#endif