blob: a035e783768f53e2080d1cfaaab46d5bfc852ff8 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* -------------------------------------------
Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
#include <lib/cxx-abi.h>
/// BUGS: 0
extern "C" __SIZE_TYPE__ mp_put_string(const char* text);
extern "C" void mp_panic(const char* reason);
extern "C" void __stack_chk_fail()
{
mp_put_string("[stack-canary] Buffer overflow detected, halting...\n");
mp_panic("stack_canary_fail");
}
void* __dso_handle;
extern "C" __SIZE_TYPE__ mp_put_string(const char* text);
extern "C" void mp_panic(const char* reason);
atexit_func_entry_t __atexit_funcs[DSO_MAX_OBJECTS];
uarch_t __atexit_func_count;
extern "C" void __cxa_pure_virtual()
{
mp_put_string("[__cxa_pure_virtual] Placeholder\n");
}
extern "C" int __cxa_atexit(void (*f)(void*), void* arg, void* dso)
{
if (__atexit_func_count >= DSO_MAX_OBJECTS)
return -1;
__atexit_funcs[__atexit_func_count].destructor_func = f;
__atexit_funcs[__atexit_func_count].obj_ptr = arg;
__atexit_funcs[__atexit_func_count].dso_handle = dso;
__atexit_func_count++;
return 0;
}
extern "C" void __cxa_finalize(void* f)
{
uarch_t i = __atexit_func_count;
if (!f)
{
while (i--)
{
if (__atexit_funcs[i].destructor_func)
{
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
};
}
return;
}
while (i--)
{
if (__atexit_funcs[i].destructor_func)
{
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
__atexit_funcs[i].destructor_func = 0;
};
}
}
namespace cxxabiv1
{
extern "C" int __cxa_guard_acquire(__guard* g)
{
(void)g;
return 0;
}
extern "C" int __cxa_guard_release(__guard* g)
{
*(char*)g = 1;
return 0;
}
extern "C" void __cxa_guard_abort(__guard* g)
{
(void)g;
}
} // namespace cxxabiv1
|