xref: /linux/tools/objtool/tests/generic/fixtures/symid_discarded.c (revision 5b6dca02b3e2254d2fd5706d76d7ab4610a67296)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Compiled twice and partially linked so the result has duplicate locals,
4  * which is what symid_needed() requires.  dup_normal is in a live section,
5  * dup_discarded in one the vmlinux link throws away.  DISCARDED_SEC selects
6  * which discarded section, since there is more than one and each was its own
7  * bug.
8  */
9 
10 #ifndef DISCARDED_SEC
11 #define DISCARDED_SEC ".exitcall.exit"
12 #endif
13 
14 static const char __modinfo[]
15 	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
16 
17 static int dup_normal = 1;
18 
19 static void *dup_discarded
20 	__attribute__((section(DISCARDED_SEC), used)) = &dup_normal;
21 
FUNC_NAME(void)22 int FUNC_NAME(void)
23 {
24 	return dup_normal + (dup_discarded != (void *)0);
25 }
26