1 //===-- hwasan_memintrinsics.cc ---------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file is a part of HWAddressSanitizer and contains HWASAN versions of
12 /// memset, memcpy and memmove
14 //===----------------------------------------------------------------------===//
18 #include "hwasan_checks.h"
19 #include "hwasan_flags.h"
20 #include "hwasan_interface_internal.h"
21 #include "sanitizer_common/sanitizer_libc.h"
23 using namespace __hwasan;
25 void *__hwasan_memset(void *block, int c, uptr size) {
26 CheckAddressSized<ErrorAction::Recover, AccessType::Store>(
27 reinterpret_cast<uptr>(block), size);
28 return memset(UntagPtr(block), c, size);
31 void *__hwasan_memcpy(void *to, const void *from, uptr size) {
32 CheckAddressSized<ErrorAction::Recover, AccessType::Store>(
33 reinterpret_cast<uptr>(to), size);
34 CheckAddressSized<ErrorAction::Recover, AccessType::Load>(
35 reinterpret_cast<uptr>(from), size);
36 return memcpy(UntagPtr(to), UntagPtr(from), size);
39 void *__hwasan_memmove(void *to, const void *from, uptr size) {
40 CheckAddressSized<ErrorAction::Recover, AccessType::Store>(
41 reinterpret_cast<uptr>(to), size);
42 CheckAddressSized<ErrorAction::Recover, AccessType::Load>(
43 reinterpret_cast<uptr>(from), size);
44 return memmove(UntagPtr(to), UntagPtr(from), size);