summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/fixtures/cross_module.c
blob: c170bde0666f4041111f088e49c7794395c96e09 (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
// SPDX-License-Identifier: GPL-2.0
/*
 * A function which calls out to another object.  MODNAME selects which object
 * this one is, so a test can make the caller a module and the callee's owner
 * something else.
 */

#ifndef MODNAME
#define MODNAME "vmlinux"
#endif

/* klp diff takes the object's module name from .modinfo */
static const char __modinfo[]
	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=" MODNAME;

extern int other_mod_func(int x);

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