OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file implements the native methods of | 5 // This file implements the native methods of |
6 // org.content.chromium.app.LinkerTests | 6 // org.content.chromium.app.LinkerTests |
7 // Unlike the content of linker_jni.cc, it is part of the content library and | 7 // Unlike the content of linker_jni.cc, it is part of the content library and |
8 // can thus use base/ and the C++ STL. | 8 // can thus use base/ and the C++ STL. |
9 | 9 |
10 #include "content/shell/android/linker_test_apk/chromium_linker_test_linker_test
s.h" | 10 #include "content/shell/android/linker_test_apk/chromium_linker_test_linker_test
s.h" |
11 | 11 |
| 12 #include <errno.h> |
| 13 #include <stddef.h> |
| 14 #include <stdint.h> |
| 15 #include <stdio.h> |
12 #include <sys/mman.h> | 16 #include <sys/mman.h> |
13 #include <errno.h> | |
14 #include <stdio.h> | |
15 #include <string> | 17 #include <string> |
16 #include <vector> | 18 #include <vector> |
17 | 19 |
18 #include "base/basictypes.h" | |
19 #include "base/debug/proc_maps_linux.h" | 20 #include "base/debug/proc_maps_linux.h" |
20 #include "base/logging.h" | 21 #include "base/logging.h" |
21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
22 #include "jni/LinkerTests_jni.h" | 23 #include "jni/LinkerTests_jni.h" |
23 #include "third_party/re2/src/re2/re2.h" | 24 #include "third_party/re2/src/re2/re2.h" |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Ignore any mapping that isn't a shared RELRO. | 100 // Ignore any mapping that isn't a shared RELRO. |
100 continue; | 101 continue; |
101 } | 102 } |
102 | 103 |
103 num_shared_relros++; | 104 num_shared_relros++; |
104 | 105 |
105 void* region_start = reinterpret_cast<void*>(region.start); | 106 void* region_start = reinterpret_cast<void*>(region.start); |
106 void* region_end = reinterpret_cast<void*>(region.end); | 107 void* region_end = reinterpret_cast<void*>(region.end); |
107 | 108 |
108 // Check that it is mapped read-only. | 109 // Check that it is mapped read-only. |
109 const uint8 expected_flags = MappedMemoryRegion::READ; | 110 const uint8_t expected_flags = MappedMemoryRegion::READ; |
110 const uint8 expected_mask = MappedMemoryRegion::READ | | 111 const uint8_t expected_mask = MappedMemoryRegion::READ | |
111 MappedMemoryRegion::WRITE | | 112 MappedMemoryRegion::WRITE | |
112 MappedMemoryRegion::EXECUTE; | 113 MappedMemoryRegion::EXECUTE; |
113 | 114 |
114 uint8 region_flags = region.permissions & expected_mask; | 115 uint8_t region_flags = region.permissions & expected_mask; |
115 if (region_flags != expected_flags) { | 116 if (region_flags != expected_flags) { |
116 LOG(ERROR) | 117 LOG(ERROR) |
117 << prefix | 118 << prefix |
118 << base::StringPrintf( | 119 << base::StringPrintf( |
119 "Shared RELRO section at %p-%p is not mapped read-only. " | 120 "Shared RELRO section at %p-%p is not mapped read-only. " |
120 "Protection flags are %d (%d expected)!", | 121 "Protection flags are %d (%d expected)!", |
121 region_start, | 122 region_start, |
122 region_end, | 123 region_end, |
123 region_flags, | 124 region_flags, |
124 expected_flags); | 125 expected_flags); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 204 |
204 jboolean CheckForNoSharedRelros(JNIEnv* env, | 205 jboolean CheckForNoSharedRelros(JNIEnv* env, |
205 const JavaParamRef<jclass>& clazz, | 206 const JavaParamRef<jclass>& clazz, |
206 jboolean in_browser_process) { | 207 jboolean in_browser_process) { |
207 return RunChecks(in_browser_process, false); | 208 return RunChecks(in_browser_process, false); |
208 } | 209 } |
209 | 210 |
210 bool RegisterLinkerTestsJni(JNIEnv* env) { return RegisterNativesImpl(env); } | 211 bool RegisterLinkerTestsJni(JNIEnv* env) { return RegisterNativesImpl(env); } |
211 | 212 |
212 } // namespace content | 213 } // namespace content |
OLD | NEW |