OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <iostream> | 7 #include <iostream> |
8 #include <linux/unistd.h> | 8 #include <linux/unistd.h> |
9 #include <signal.h> | 9 #include <signal.h> |
10 #include <stdarg.h> | 10 #include <stdarg.h> |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 unsigned long position; | 214 unsigned long position; |
215 if (isStackLine(ptr, buf + len)) { | 215 if (isStackLine(ptr, buf + len)) { |
216 // If we're adjacent to the stack, try to stay away from | 216 // If we're adjacent to the stack, try to stay away from |
217 // the GROWS_DOWN region. Pick the farthest away region that | 217 // the GROWS_DOWN region. Pick the farthest away region that |
218 // is still within the gap. | 218 // is still within the gap. |
219 | 219 |
220 if (static_cast<unsigned long>(addr) < kMaxDistance || // Underfl
ow protection. | 220 if (static_cast<unsigned long>(addr) < kMaxDistance || // Underfl
ow protection. |
221 static_cast<unsigned long>(addr) - kMaxDistance < gap_start) { | 221 static_cast<unsigned long>(addr) - kMaxDistance < gap_start) { |
222 position = gap_start; | 222 position = gap_start; |
223 } else { | 223 } else { |
224 position = addr - kMaxDistance; | 224 position = (addr - kMaxDistance) & ~4095; |
| 225 if (position < gap_start) { |
| 226 position = gap_start; |
| 227 } |
225 } | 228 } |
226 } else { | 229 } else { |
227 // Otherwise, take the end of the region. | 230 // Otherwise, take the end of the region. |
228 position = gap_end - size; | 231 position = gap_end - size; |
229 } | 232 } |
230 new_addr = reinterpret_cast<char *>(sys.MMAP | 233 new_addr = reinterpret_cast<char *>(sys.MMAP |
231 (reinterpret_cast<void *>(position), size, prot, | 234 (reinterpret_cast<void *>(position), size, prot, |
232 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0)); | 235 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0)); |
233 if (new_addr != MAP_FAILED) { | 236 if (new_addr != MAP_FAILED) { |
234 goto done; | 237 goto done; |
(...skipping 21 matching lines...) Expand all Loading... |
256 break; | 259 break; |
257 } | 260 } |
258 } | 261 } |
259 } while (len || long_line); | 262 } while (len || long_line); |
260 new_addr = NULL; | 263 new_addr = NULL; |
261 done: | 264 done: |
262 return reinterpret_cast<char*>(new_addr); | 265 return reinterpret_cast<char*>(new_addr); |
263 } | 266 } |
264 | 267 |
265 } // namespace | 268 } // namespace |
OLD | NEW |