1 : // Copyright 2012 Google Inc.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Implements an all-static class that manages shadow memory for ASAN.
16 : #ifndef SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_
17 : #define SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_
18 :
19 : #include "base/basictypes.h"
20 :
21 m : namespace agent {
22 m : namespace asan {
23 :
24 : // An all-static class that manages the ASAN shadow memory.
25 m : class Shadow {
26 m : public:
27 : // Poisons @p size bytes starting at @p addr.
28 : // @pre addr + size mod 8 == 0.
29 m : static void Poison(const void* addr, size_t size);
30 :
31 : // Un-poisons @p size bytes starting at @p addr.
32 : // @pre addr mod 8 == 0 && size mod 8 == 0.
33 m : static void Unpoison(const void* addr, size_t size);
34 :
35 : // Returns true iff the byte at @p addr is not poisoned.
36 m : static bool IsAccessible(const void* addr);
37 :
38 m : private:
39 : // One shadow byte for every 8 bytes in a 4G address space.
40 m : static const size_t kShadowSize = 1 << (32 - 3);
41 m : static uint8 shadow_[kShadowSize];
42 m : };
43 :
44 m : } // namespace asan
45 m : } // namespace agent
46 :
47 : #endif // SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_
|