Max OS
0.3
Loading...
Searching...
No Matches
symbols.cpp
Go to the documentation of this file.
1
9
#include <common/symbols.h>
10
11
12
namespace
MaxOS::common {
13
23
const
char
*
resolve_symbol
(
uintptr_t
rip,
uintptr_t
link_base
,
uintptr_t
load_base
) {
24
25
// No symbols
26
if
(
KERNEL_SYMBOLS_COUNT
== 0)
27
return
nullptr
;
28
29
// Convert load to linked
30
uintptr_t
offset = 0;
31
if
(
load_base
>=
link_base
)
32
offset =
load_base
-
link_base
;
33
34
// Get the adjusted address
35
uintptr_t
adjusted_address
= rip;
36
if
(rip >= offset)
37
adjusted_address
= rip - offset;
38
39
// Binary Search for symbol
40
size_t
left = 0;
41
size_t
right
=
KERNEL_SYMBOLS_COUNT
;
42
while
(left <
right
) {
43
size_t
middle
= (left +
right
) >> 1;
44
if
(
kernel_symbols
[
middle
].address <=
adjusted_address
)
45
left =
middle
+ 1;
46
else
47
right
=
middle
;
48
}
49
50
return
left == 0 ?
nullptr
:
kernel_symbols
[left - 1].name;
51
}
52
}
MaxOS::common::Rectangle
Stores the left, top, width and height of a rectangle.
Definition
rectangle.h:22
MaxOS::common::resolve_symbol
const char * resolve_symbol(uintptr_t rip, uintptr_t link_base, uintptr_t load_base)
resolve an instruction pointer (rip) to a symbol name and optional offset.
Definition
symbols.cpp:23
kernel
src
common
symbols.cpp
Generated by
1.9.8