summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/fixtures/new_data.c
blob: ac364622f12a990893414f1f1d6bbfe07845c415 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-License-Identifier: GPL-2.0
/* Data introduced by the patch. */

static const char __modinfo[]
	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";

#ifdef PATCHED
/*
 * Not an arithmetic progression: { 1, 2, 3, 4 } indexed by x & 3 is something
 * a compiler can compute instead of load, and then target() has no reference
 * to the array and there is nothing for klp diff to carry.
 */
static const int klp_new_data[4] __attribute__((used)) = { 7, 3, 11, 5 };
#endif

int target(int x)
{
#ifdef PATCHED
	return x + klp_new_data[x & 3];
#else
	return x;
#endif
}