1 //===-- dfsan_platform.h ----------------------------------------*- 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 //===----------------------------------------------------------------------===//
10 // This file is a part of DataFlowSanitizer.
12 // Platform specific information for DFSan.
13 //===----------------------------------------------------------------------===//
15 #ifndef DFSAN_PLATFORM_H
16 #define DFSAN_PLATFORM_H
20 #if defined(__x86_64__)
22 static const uptr kShadowAddr = 0x10000;
23 static const uptr kUnionTableAddr = 0x200000000000;
24 static const uptr kAppAddr = 0x700000008000;
25 static const uptr kShadowMask = ~0x700000000000;
27 #elif defined(__mips64)
29 static const uptr kShadowAddr = 0x10000;
30 static const uptr kUnionTableAddr = 0x2000000000;
31 static const uptr kAppAddr = 0xF000008000;
32 static const uptr kShadowMask = ~0xF000000000;
34 #elif defined(__aarch64__)
36 static const uptr kShadowAddr = 0x10000;
37 static const uptr kUnionTableAddr = 0x1000000000;
38 static const uptr kAppAddr = 0x7000008000;
39 static const uptr kShadowMask = ~0x7800000000;
43 static const uptr kShadowAddr = 0x10000;
44 static const uptr kUnionTableAddr = 0x8000000000;
45 static const uptr kAppAddr = 0x3ff00008000;
46 static const uptr kShadowMask = ~0x3c000000000;
50 # define DFSAN_RUNTIME_VMA 1
52 # error "DFSan not supported for this platform!"
57 MAPPING_UNION_TABLE_ADDR,
62 template<typename Mapping, int Type>
63 uptr MappingImpl(void) {
65 case MAPPING_SHADOW_ADDR: return Mapping::kShadowAddr;
66 case MAPPING_UNION_TABLE_ADDR: return Mapping::kUnionTableAddr;
67 case MAPPING_APP_ADDR: return Mapping::kAppAddr;
68 case MAPPING_SHADOW_MASK: return Mapping::kShadowMask;
73 uptr MappingArchImpl(void) {
76 return MappingImpl<Mapping39, Type>();
78 return MappingImpl<Mapping42, Type>();
81 return MappingImpl<Mapping, Type>();
87 return MappingArchImpl<MAPPING_SHADOW_ADDR>();
91 uptr UnionTableAddr() {
92 return MappingArchImpl<MAPPING_UNION_TABLE_ADDR>();
97 return MappingArchImpl<MAPPING_APP_ADDR>();
102 return MappingArchImpl<MAPPING_SHADOW_MASK>();
105 } // namespace __dfsan