20
20
# include < unistd.h>
21
21
# include < fcntl.h>
22
22
# include < time.h>
23
+ # include < errno.h>
23
24
# include < wasi/api.h>
24
25
25
26
# include " sanitizer_common.h"
31
32
# include " sanitizer_stacktrace.h"
32
33
# include " sanitizer_symbolizer_internal.h"
33
34
34
- # include " ../asan/wasi/dlmalloc.c"
35
-
36
35
namespace __sanitizer {
37
36
37
+ extern " C" void *__libc_malloc (uptr);
38
+ extern " C" void __libc_free (void *);
39
+
38
40
void InitializePlatformEarly () {}
39
41
void InitTlsSize () {}
40
42
@@ -44,7 +46,7 @@ uptr GetPageSize() { return PAGESIZE; }
44
46
45
47
void *MmapOrDie (uptr size, const char *mem_type, bool raw_report) {
46
48
size = RoundUpTo (size, GetPageSize ());
47
- void *ptr = dlmalloc (size);
49
+ void *ptr = __libc_malloc (size);
48
50
if (!ptr) {
49
51
if (raw_report) {
50
52
Report (" MmapOrDie: failed to allocate %zu bytes\n " , size);
@@ -55,7 +57,7 @@ void *MmapOrDie(uptr size, const char *mem_type, bool raw_report) {
55
57
}
56
58
57
59
void UnmapOrDie (void *addr, uptr size, bool raw_report) {
58
- dlfree (addr);
60
+ __libc_free (addr);
59
61
}
60
62
61
63
void *MmapNoReserveOrDie (uptr size, const char *mem_type) {
@@ -68,12 +70,14 @@ void DumpProcessMap() {
68
70
69
71
// Implement mandatory functions for ASan WASI build
70
72
void CheckASLR () {}
73
+ void PlatformPrepareForSandboxing (void *args) {}
71
74
void DisableCoreDumperIfNecessary () {}
72
75
void InstallDeadlySignalHandlers (void (*cb)(int , void *, void *)) {}
73
76
int Atexit (void (*function)(void )) { return 0 ; }
74
77
uptr GetMaxUserVirtualAddress () { return (1ULL << 30 ); } // 1GB for WASI
75
78
uptr GetMmapGranularity () { return GetPageSize (); }
76
79
uptr internal_sched_yield () { return 0 ; }
80
+ void internal_join_thread (void *th) {}
77
81
bool MemoryRangeIsAvailable (uptr beg, uptr size) { return true ; }
78
82
void GetThreadStackAndTls (bool main, uptr *stk_addr, uptr *stk_size,
79
83
uptr *tls_addr, uptr *tls_size) {
@@ -94,7 +98,7 @@ void Symbolizer::LateInitialize() {
94
98
// Additional mandatory functions
95
99
void *MmapOrDieOnFatalError (uptr size, const char *mem_type) {
96
100
size = RoundUpTo (size, GetPageSizeCached ()) + GetPageSizeCached ();
97
- void *ptr = dlmalloc (size);
101
+ void *ptr = __libc_malloc (size);
98
102
if (!ptr) {
99
103
Report (" MmapOrDieOnFatalError: failed to allocate %zu bytes\n " , size);
100
104
Die ();
0 commit comments