summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/fixtures/sympos_dup.c
blob: 7eded9b12cfc8064bd231876cd4d785dcd71c828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-License-Identifier: GPL-2.0
/*
 * A static whose name recurs in every translation unit that includes it.
 * Compiled once for a single-copy object and twice, partially linked, for one
 * with duplicates -- which is the only case where sympos is non-zero.
 *
 * FUNC_NAME keeps the referencing functions distinct so both get patched.
 * Only the first copy carries .modinfo; two would be a second thing to
 * disambiguate and is not what this fixture is about.
 */

#ifndef FUNC_NAME
#define FUNC_NAME use_a
#endif

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

/* volatile so it survives as an STT_OBJECT rather than being folded away */
static volatile int dup_counter = 1;

int FUNC_NAME(int x)
{
	dup_counter += x;
#ifdef PATCHED
	return dup_counter + 1;
#else
	return dup_counter;
#endif
}