Messages in this thread | | | Date | Fri, 10 Feb 2023 20:25:00 +0100 | From | Jakub Jelinek <> | Subject | Re: [PATCH -tip] kasan: Emit different calls for instrumentable memintrinsics |
| |
On Wed, Feb 08, 2023 at 07:42:03PM +0100, Marco Elver wrote: > Clang 15 will provide an option to prefix calls to memcpy/memset/memmove > with __asan_ in instrumented functions: https://reviews.llvm.org/D122724 > > GCC does not yet have similar support.
GCC has support to rename memcpy/memset etc. for years, say on following compiled with -fsanitize=kernel-address -O2 -mstringop-strategy=libcall (the last option just to make sure the compiler doesn't prefer to emit rep mov*/stos* or loop or something similar, of course kernel can keep whatever it uses) you'll get just __asan_memcpy/__asan_memset calls, no memcpy/memset, while without -fsanitize=kernel-address you get normally memcpy/memset. Or do you need the __asan_* functions only in asan instrumented functions and normal ones in non-instrumented functions in the same TU?
#ifdef __SANITIZE_ADDRESS__ extern __typeof (__builtin_memcpy) memcpy __asm ("__asan_memcpy"); extern __typeof (__builtin_memset) memset __asm ("__asan_memset"); #endif struct S { char a[2048]; } a, b;
void foo (void) { a = b; b = (struct S) {}; }
void bar (void *p, void *q, int s) { memcpy (p, q, s); }
void baz (void *p, int c, int s) { memset (p, c, s); }
void qux (void *p, void *q, int s) { __builtin_memcpy (p, q, s); }
void quux (void *p, int c, int s) { __builtin_memset (p, c, s); }
Jakub
| |