xref: /openbmc/linux/tools/perf/arch/arm64/util/machine.c (revision bd4af432)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <stdio.h>
4 #include <string.h>
5 #include "debug.h"
6 #include "symbol.h"
7 
8 /* On arm64, kernel text segment start at high memory address,
9  * for example 0xffff 0000 8xxx xxxx. Modules start at a low memory
10  * address, like 0xffff 0000 00ax xxxx. When only samll amount of
11  * memory is used by modules, gap between end of module's text segment
12  * and start of kernel text segment may be reach 2G.
13  * Therefore do not fill this gap and do not assign it to the kernel dso map.
14  */
15 
16 #define SYMBOL_LIMIT (1 << 12) /* 4K */
17 
18 void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
19 {
20 	if ((strchr(p->name, '[') && strchr(c->name, '[') == NULL) ||
21 			(strchr(p->name, '[') == NULL && strchr(c->name, '[')))
22 		/* Limit range of last symbol in module and kernel */
23 		p->end += SYMBOL_LIMIT;
24 	else
25 		p->end = c->start;
26 	pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end);
27 }
28