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) { |
Mark Seaborn
2015/07/30 15:20:14
Nit: use "(NACL_ABI_MAP_FIXED & flags) != 0"
NaCl
Sean Klein
2015/07/30 16:04:29
Done.
| |
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; |
Mark Seaborn
2015/07/30 15:20:14
Is there a test case covering this code path?
Sean Klein
2015/07/30 16:04:29
There is now (added to mem_test.cc).
| |
335 goto cleanup; | |
336 } else { | |
337 /* Ignore the hint, as we do not need it. */ | |
Mark Seaborn
2015/07/30 15:20:14
So we use the hint if it's aligned but ignore it o
Sean Klein
2015/07/30 16:04:29
Linux rounds the address to a minimum value, and t
| |
338 NaClLog(2, "NaClSysMmap: ignoring misaligned hint address\n"); | |
339 usraddr = 0; | |
340 } | |
335 } | 341 } |
336 /* | 342 /* |
337 * Offset should be non-negative (nacl_abi_off_t is signed). This | 343 * 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 | 344 * condition is caught when the file is stat'd and checked, and |
339 * offset is ignored for anonymous mappings. | 345 * offset is ignored for anonymous mappings. |
340 */ | 346 */ |
341 if (offset < 0) { | 347 if (offset < 0) { |
342 NaClLog(1, /* application bug */ | 348 NaClLog(1, /* application bug */ |
343 "NaClSysMmap: negative file offset: %"NACL_PRId64"\n", | 349 "NaClSysMmap: negative file offset: %"NACL_PRId64"\n", |
344 (int64_t) offset); | 350 (int64_t) offset); |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1368 size_t length, | 1374 size_t length, |
1369 int prot) { | 1375 int prot) { |
1370 struct NaClApp *nap = natp->nap; | 1376 struct NaClApp *nap = natp->nap; |
1371 | 1377 |
1372 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " | 1378 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " |
1373 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", | 1379 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", |
1374 (uintptr_t) natp, (uintptr_t) start, length, prot); | 1380 (uintptr_t) natp, (uintptr_t) start, length, prot); |
1375 | 1381 |
1376 return NaClSysMprotectInternal(nap, start, length, prot); | 1382 return NaClSysMprotectInternal(nap, start, length, prot); |
1377 } | 1383 } |
OLD | NEW |