1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#include "mos/misc/kallsyms.h"
4
5const kallsyms_t *kallsyms_get_symbol(ptr_t addr)
6{
7 // kallsyms are sorted by address
8 const kallsyms_t *ks = mos_kallsyms;
9 const kallsyms_t *result = NULL;
10
11 while (ks->name)
12 {
13 if (ks->address > addr)
14 break;
15 result = ks;
16 ks++;
17 }
18
19 return result;
20}
21
22const char *kallsyms_get_symbol_name(ptr_t addr)
23{
24 const kallsyms_t *ks = kallsyms_get_symbol(addr);
25 return ks ? ks->name : "<unknown>";
26}
27