6 int main() { printf("main\n"); }
10 if (pc == reinterpret_cast<uintptr_t>(X)) \
13 const char *symbolize(uintptr_t pc
) {
18 template <typename T
> T
consume(const char *&pos
, const char *end
) {
20 // We need to memcpy from pos, because it's not guaranteed that every entry
21 // has the required alignment of T.
22 memcpy(&v
, pos
, sizeof(T
));
28 uint64_t consume_uleb128(const char *&pos
, const char *end
) {
34 val
|= uint64_t{cur
& 0x7fu
} << shift
;
42 constexpr uint32_t kSanitizerBinaryMetadataUARHasSize
= 1 << 2;
44 uint32_t meta_version
;
45 const char *meta_start
;
47 const char *atomics_start
;
48 const char *atomics_end
;
52 void __sanitizer_metadata_covered_add(uint32_t version
, const char *start
,
54 const uint32_t version_base
= version
& 0xffff;
55 const bool offset_ptr_sized
= version
& (1 << 16);
56 assert(version_base
== 2);
57 printf("metadata add version %u\n", version_base
);
58 for (const char *pos
= start
; pos
< end
;) {
59 const auto base
= reinterpret_cast<uintptr_t>(pos
);
60 const intptr_t offset
= offset_ptr_sized
? consume
<intptr_t>(pos
, end
)
61 : consume
<int32_t>(pos
, end
);
62 [[maybe_unused
]] const uint64_t size
= consume_uleb128(pos
, end
);
63 const uint64_t features
= consume_uleb128(pos
, end
);
64 uint64_t stack_args
= 0;
65 if (features
& kSanitizerBinaryMetadataUARHasSize
)
66 stack_args
= consume_uleb128(pos
, end
);
67 if (const char *name
= symbolize(base
+ offset
))
68 printf("%s: features=%lx stack_args=%lu\n", name
, features
, stack_args
);
70 meta_version
= version
;
75 void __sanitizer_metadata_covered_del(uint32_t version
, const char *start
,
77 assert(version
== meta_version
);
78 assert(start
== meta_start
);
79 assert(end
== meta_end
);
82 void __sanitizer_metadata_atomics_add(uint32_t version
, const char *start
,
84 assert(version
== meta_version
);
87 atomics_start
= start
;
91 void __sanitizer_metadata_atomics_del(uint32_t version
, const char *start
,
93 assert(version
== meta_version
);
94 assert(atomics_start
== start
);
95 assert(atomics_end
== end
);