1 //===-- dfsan_platform.h ----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of DataFlowSanitizer.
11 // Platform specific information for DFSan.
12 //===----------------------------------------------------------------------===//
14 #ifndef DFSAN_PLATFORM_H
15 #define DFSAN_PLATFORM_H
19 #if defined(__x86_64__)
21 static const uptr kShadowAddr = 0x10000;
22 static const uptr kUnionTableAddr = 0x200000000000;
23 static const uptr kAppAddr = 0x700000008000;
24 static const uptr kShadowMask = ~0x700000000000;
26 #elif defined(__mips64)
28 static const uptr kShadowAddr = 0x10000;
29 static const uptr kUnionTableAddr = 0x2000000000;
30 static const uptr kAppAddr = 0xF000008000;
31 static const uptr kShadowMask = ~0xF000000000;
33 #elif defined(__aarch64__)
35 static const uptr kShadowAddr = 0x10000;
36 static const uptr kUnionTableAddr = 0x1000000000;
37 static const uptr kAppAddr = 0x7000008000;
38 static const uptr kShadowMask = ~0x7800000000;
42 static const uptr kShadowAddr = 0x10000;
43 static const uptr kUnionTableAddr = 0x8000000000;
44 static const uptr kAppAddr = 0x3ff00008000;
45 static const uptr kShadowMask = ~0x3c000000000;
49 static const uptr kShadowAddr = 0x10000;
50 static const uptr kUnionTableAddr = 0x8000000000;
51 static const uptr kAppAddr = 0xffff00008000;
52 static const uptr kShadowMask = ~0xfffff0000000;
56 # define DFSAN_RUNTIME_VMA 1
58 # error "DFSan not supported for this platform!"
63 MAPPING_UNION_TABLE_ADDR,
68 template<typename Mapping, int Type>
69 uptr MappingImpl(void) {
71 case MAPPING_SHADOW_ADDR: return Mapping::kShadowAddr;
72 case MAPPING_UNION_TABLE_ADDR: return Mapping::kUnionTableAddr;
73 case MAPPING_APP_ADDR: return Mapping::kAppAddr;
74 case MAPPING_SHADOW_MASK: return Mapping::kShadowMask;
79 uptr MappingArchImpl(void) {
82 case 39: return MappingImpl<Mapping39, Type>();
83 case 42: return MappingImpl<Mapping42, Type>();
84 case 48: return MappingImpl<Mapping48, Type>();
89 return MappingImpl<Mapping, Type>();
95 return MappingArchImpl<MAPPING_SHADOW_ADDR>();
99 uptr UnionTableAddr() {
100 return MappingArchImpl<MAPPING_UNION_TABLE_ADDR>();
105 return MappingArchImpl<MAPPING_APP_ADDR>();
110 return MappingArchImpl<MAPPING_SHADOW_MASK>();
113 } // namespace __dfsan