-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkallsyms.c
33 lines (26 loc) · 896 Bytes
/
kallsyms.c
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
#include <stddef.h>
#include <stdint.h>
#include "kallsyms.h"
extern unsigned int kallsym_table_cnt __attribute((weak));
extern struct symbol kallsym_table[] __attribute((weak));
const struct symbol* addr_to_symbol(uint64_t addr)
{
unsigned int start, end, middle;
start = 0;
end = kallsym_table_cnt;
while (1) {
middle = (start + end) / 2;
if (start == middle)
break;
if (kallsym_table[middle].addr < addr)
start = middle;
else if (kallsym_table[middle].addr > addr)
end = middle;
else
return kallsym_table+middle;
}
if (kallsym_table[middle].addr > addr)
return NULL;
else
return kallsym_table+middle;
}