Skip to content

Commit eaf36c6

Browse files
authored
[ASan] Update meminstrinsics to use library memmove rather than internal (#160740)
Currently `memcpy` and `memset` intrinsics map through to the library implementations if ASan has been inited, whereas `memmove` always calls `internal_memmove`. This patch changes `memmove` to use the library implementation if ASan has been inited.
1 parent 9be276e commit eaf36c6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ using namespace __asan;
5555
if (LIKELY(replace_intrin_cached)) { \
5656
ASAN_READ_RANGE(ctx, from, size); \
5757
ASAN_WRITE_RANGE(ctx, to, size); \
58+
} else if (UNLIKELY(!AsanInited())) { \
59+
return internal_memmove(to, from, size); \
5860
} \
59-
return internal_memmove(to, from, size); \
61+
return REAL(memmove)(to, from, size); \
6062
} while (0)
6163

6264
void *__asan_memcpy(void *to, const void *from, uptr size) {

compiler-rt/lib/asan/asan_interceptors_memintrinsics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
DECLARE_REAL(void *, memcpy, void *to, const void *from, SIZE_T size)
2222
DECLARE_REAL(void *, memset, void *block, int c, SIZE_T size)
23+
DECLARE_REAL(void *, memmove, void *to, const void *from, SIZE_T size)
2324

2425
namespace __asan {
2526

0 commit comments

Comments
 (0)