blob: 973bdc10295df37535d4dca5c56bb1521c76dd4d (
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
41
42
43
44
45
46
47
|
// SPDX-License-Identifier: GPL-2.0
/*
* Symbols calculate_checksums() must not give an entry of their own.
*
* Three kinds are skipped, for two different reasons:
*
* zero-length there is nothing to hash, and an entry keyed on the
* symbol's address would collide with whatever really lives
* there.
* alias a second name for an address already checksummed.
* cold part hashed as part of its parent, which func_for_each_insn()
* walks into, so a separate entry would double-count it.
*
* An entry per address is the invariant: .discard.sym_checksum is looked up by
* the address a relocation points at, so two entries for one address make the
* lookup ambiguous and one of the two checksums unreachable.
*/
static const char __modinfo[]
__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
/* Zero-length: an object symbol of size 0, in a section of its own. */
extern char empty_marker[];
__asm__(".pushsection .data.empty_marker,\"aw\",@progbits\n"
".globl empty_marker\n"
".type empty_marker, @object\n"
"empty_marker:\n"
".size empty_marker, 0\n"
".popsection\n");
int real_function(int x);
int real_function(int x)
{
#ifdef PATCHED
return x + 2;
#else
return x + 1;
#endif
}
/* Alias: a second name for real_function's address. */
int alias_function(int x) __attribute__((alias("real_function")));
int target(int x)
{
return real_function(x) + alias_function(x) + (int)(long)empty_marker;
}
|