OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "native_client/src/trusted/service_runtime/sys_memory.h" | 7 #include "native_client/src/trusted/service_runtime/sys_memory.h" |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } else if (0 != (prot & NACL_ABI_PROT_EXEC)) { | 322 } else if (0 != (prot & NACL_ABI_PROT_EXEC)) { |
323 map_result = -NACL_ABI_EINVAL; | 323 map_result = -NACL_ABI_EINVAL; |
324 goto cleanup; | 324 goto cleanup; |
325 } | 325 } |
326 | 326 |
327 /* | 327 /* |
328 * Starting address must be aligned to worst-case allocation | 328 * Starting address must be aligned to worst-case allocation |
329 * granularity. (Windows.) | 329 * granularity. (Windows.) |
330 */ | 330 */ |
331 if (!NaClIsAllocPageMultiple(usraddr)) { | 331 if (!NaClIsAllocPageMultiple(usraddr)) { |
332 NaClLog(2, "NaClSysMmap: address not allocation granularity aligned\n"); | 332 if ((NACL_ABI_MAP_FIXED & flags) != 0) { |
333 map_result = -NACL_ABI_EINVAL; | 333 NaClLog(2, "NaClSysMmap: address not allocation granularity aligned\n"); |
334 goto cleanup; | 334 map_result = -NACL_ABI_EINVAL; |
| 335 goto cleanup; |
| 336 } else { |
| 337 NaClLog(2, "NaClSysMmap: Force alignment of misaligned hint address\n"); |
| 338 usraddr = NaClTruncAllocPage(usraddr); |
| 339 } |
335 } | 340 } |
336 /* | 341 /* |
337 * Offset should be non-negative (nacl_abi_off_t is signed). This | 342 * Offset should be non-negative (nacl_abi_off_t is signed). This |
338 * condition is caught when the file is stat'd and checked, and | 343 * condition is caught when the file is stat'd and checked, and |
339 * offset is ignored for anonymous mappings. | 344 * offset is ignored for anonymous mappings. |
340 */ | 345 */ |
341 if (offset < 0) { | 346 if (offset < 0) { |
342 NaClLog(1, /* application bug */ | 347 NaClLog(1, /* application bug */ |
343 "NaClSysMmap: negative file offset: %"NACL_PRId64"\n", | 348 "NaClSysMmap: negative file offset: %"NACL_PRId64"\n", |
344 (int64_t) offset); | 349 (int64_t) offset); |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1368 size_t length, | 1373 size_t length, |
1369 int prot) { | 1374 int prot) { |
1370 struct NaClApp *nap = natp->nap; | 1375 struct NaClApp *nap = natp->nap; |
1371 | 1376 |
1372 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " | 1377 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " |
1373 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", | 1378 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", |
1374 (uintptr_t) natp, (uintptr_t) start, length, prot); | 1379 (uintptr_t) natp, (uintptr_t) start, length, prot); |
1375 | 1380 |
1376 return NaClSysMprotectInternal(nap, start, length, prot); | 1381 return NaClSysMprotectInternal(nap, start, length, prot); |
1377 } | 1382 } |
OLD | NEW |