projects/linux·blob master · refs

31 lines · 593 B

1// SPDX-License-Identifier: GPL-2.0
2/* Two functions contribute to one special section; only one is patched. */
3
4static const char __modinfo[]
5 __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
6
7int other(int x)
8{
9 asm volatile(
10 "2:\n\t"
11 ".pushsection .kcfi_traps, \"a\"\n\t"
12 ".balign 4\n\t"
13 ".long 2b - .\n\t"
14 ".popsection\n\t");
15 return x * 5;
16}
17
18int target(int x)
19{
20 asm volatile(
21 "1:\n\t"
22 ".pushsection .kcfi_traps, \"a\"\n\t"
23 ".balign 4\n\t"
24 ".long 1b - .\n\t"
25 ".popsection\n\t");
26#ifdef PATCHED
27 return x + 2;
28#else
29 return x + 1;
30#endif
31}