| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 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 <assert.h> | 7 #include <assert.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <nacl/nacl_dyncode.h> | 11 #include <nacl/nacl_dyncode.h> |
| 12 | 12 |
| 13 #include "native_client/src/include/arm_sandbox.h" | 13 #include "native_client/src/include/arm_sandbox.h" |
| 14 #include "native_client/tests/dynamic_code_loading/dynamic_segment.h" | 14 #include "native_client/tests/dynamic_code_loading/dynamic_segment.h" |
| 15 | 15 |
| 16 | 16 |
| 17 #if defined(__i386__) || defined(__x86_64__) | 17 #if defined(__i386__) || defined(__x86_64__) |
| 18 uint8_t halts = 0xf4; /* HLT */ | 18 uint8_t halts = 0xf4; /* HLT */ |
| 19 #elif defined(__arm__) | 19 #elif defined(__arm__) |
| 20 uint32_t halts = NACL_INSTR_HALT_FILL; | 20 uint32_t halts = NACL_INSTR_ARM_HALT_FILL; |
| 21 #else | 21 #else |
| 22 # error "Unknown arch" | 22 # error "Unknown arch" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 | 25 |
| 26 void load_into_page(uint8_t *dest) { | 26 void load_into_page(uint8_t *dest) { |
| 27 uint8_t buf[32]; | 27 uint8_t buf[32]; |
| 28 int rc; | 28 int rc; |
| 29 uint8_t *ptr; | 29 uint8_t *ptr; |
| 30 | 30 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 56 load_into_page(dyncode + DYNAMIC_CODE_PAGE_SIZE * 2); | 56 load_into_page(dyncode + DYNAMIC_CODE_PAGE_SIZE * 2); |
| 57 | 57 |
| 58 printf("Attempting to read from unallocated dyncode page. " | 58 printf("Attempting to read from unallocated dyncode page. " |
| 59 "This should fault...\n"); | 59 "This should fault...\n"); |
| 60 fprintf(stderr, "** intended_exit_status=untrusted_segfault\n"); | 60 fprintf(stderr, "** intended_exit_status=untrusted_segfault\n"); |
| 61 value = dyncode[DYNAMIC_CODE_PAGE_SIZE]; | 61 value = dyncode[DYNAMIC_CODE_PAGE_SIZE]; |
| 62 printf("Failed: Dynamic code page was readable and contained the " | 62 printf("Failed: Dynamic code page was readable and contained the " |
| 63 "byte 0x%x.\n", value); | 63 "byte 0x%x.\n", value); |
| 64 return 1; | 64 return 1; |
| 65 } | 65 } |
| OLD | NEW |