summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/fixtures/init_reference.c
blob: 9e59bdf708d3c111e763b7fd88c133f06b209e79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// SPDX-License-Identifier: GPL-2.0
/* Patched function referencing data in an .init section. */

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

/* volatile so the read cannot be folded into a constant, leaving no reference */
static volatile int init_only __attribute__((section(".init.data"), used)) = 5;

int target(int x)
{
#ifdef PATCHED
	return x + init_only + 1;
#else
	return x + init_only;
#endif
}