[asan][test] Additional test requiring weak symbol for dyld64.

Extension of D127929

rdar://80997227

Differential Revision: https://reviews.llvm.org/D130499
This commit is contained in:
Roy Sundahl 2022-07-25 09:31:02 -07:00
parent 595fc59f74
commit 1850a7a9ca
2 changed files with 13 additions and 6 deletions

View file

@ -8,14 +8,17 @@
static void *glob_ptr;
extern "C" {
void __sanitizer_free_hook(const volatile void *ptr) {
// Required for dyld macOS 12.0+
#if (__APPLE__)
__attribute__((weak))
#endif
extern "C" void
__sanitizer_free_hook(const volatile void *ptr) {
if (ptr == glob_ptr) {
*(int*)ptr = 0;
write(1, "FreeHook\n", sizeof("FreeHook\n"));
}
}
}
int main() {
int *x = (int*)malloc(100);

View file

@ -7,14 +7,18 @@
static void *glob_ptr;
extern "C" {
void __sanitizer_free_hook(const volatile void *ptr) {
// (Speculative fix if memprof is enabled on Apple platforms)
// Required for dyld macOS 12.0+
#if (__APPLE__)
__attribute__((weak))
#endif
extern "C" void
__sanitizer_free_hook(const volatile void *ptr) {
if (ptr == glob_ptr) {
*(int *)ptr = 0;
write(1, "FreeHook\n", sizeof("FreeHook\n"));
}
}
}
int main() {
int *x = (int *)malloc(100);