1 // RUN: %clangxx_msan -O0 %s -o %t && %run %t
3 // Check that strlen() and similar intercepted functions can be called on shadow
5 // The mem_to_shadow's part might need rework
15 const char *mem_to_shadow(const char *p
) {
16 #if defined(__x86_64__)
17 return (char *)((uintptr_t)p
^ 0x500000000000ULL
);
18 #elif defined (__mips64)
19 return (char *)((uintptr_t)p
^ 0x8000000000ULL
);
20 #elif defined(__powerpc64__)
21 #define LINEARIZE_MEM(mem) \
22 (((uintptr_t)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL)
23 return (char *)(LINEARIZE_MEM(p
) + 0x080000000000ULL
);
24 #elif defined(__aarch64__)
25 return (char *)((uintptr_t)p
^ 0x6000000000ULL
);
30 const char *s
= "abcdef";
31 assert(strlen(s
) == 6);
32 assert(strlen(mem_to_shadow(s
)) == 0);
34 char *t
= new char[42];
36 assert(strlen(mem_to_shadow(t
)) == 41);