blob: d5e70994c582d13f6febaa0b9fc8485ab1e05ce2 (
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// SPDX-License-Identifier: GPL-2.0
/*
* Two translation units with a same-named static, placed so that the linker
* puts them in the opposite order to the one they appear in the symbol table.
*
* VARSEC selects the section the static lands in. Linking with
* --sort-section=name then orders them alphabetically rather than by object
* order, so the first symbol in the symbol table ends up at the *higher*
* address. That is the whole point: counting symbol table order and reading
* the linked image's addresses now give different answers, which is what makes
* it possible to tell which one klp diff used.
*
* Only use_a is patched, so exactly one sympos is emitted and there is nothing
* to attribute.
*/
#ifndef FUNC_NAME
#define FUNC_NAME use_a
#endif
#ifndef VARSEC
#define VARSEC ".data.mmm"
#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 __attribute__((section(VARSEC))) = 1;
int FUNC_NAME(int x)
{
dup_counter += x;
#ifdef PATCHED
return dup_counter + 1;
#else
return dup_counter;
#endif
}
|