| 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 "native_client/tests/dynamic_code_loading/dynamic_load_test.h" | 7 #include "native_client/tests/dynamic_code_loading/dynamic_load_test.h" |
| 8 | 8 |
| 9 #include <assert.h> | 9 #include <assert.h> |
| 10 #include <errno.h> | 10 #include <errno.h> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 fill_int32(data, size, 0xe1a00000); /* NOP (MOV r0, r0) */ | 75 fill_int32(data, size, 0xe1a00000); /* NOP (MOV r0, r0) */ |
| 76 #else | 76 #else |
| 77 # error "Unknown arch" | 77 # error "Unknown arch" |
| 78 #endif | 78 #endif |
| 79 } | 79 } |
| 80 | 80 |
| 81 void fill_hlts(uint8_t *data, size_t size) { | 81 void fill_hlts(uint8_t *data, size_t size) { |
| 82 #if defined(__i386__) || defined(__x86_64__) | 82 #if defined(__i386__) || defined(__x86_64__) |
| 83 memset(data, 0xf4, size); /* HLTs */ | 83 memset(data, 0xf4, size); /* HLTs */ |
| 84 #elif defined(__arm__) | 84 #elif defined(__arm__) |
| 85 fill_int32(data, size, NACL_INSTR_HALT_FILL); | 85 fill_int32(data, size, NACL_INSTR_ARM_HALT_FILL); |
| 86 #else | 86 #else |
| 87 # error "Unknown arch" | 87 # error "Unknown arch" |
| 88 #endif | 88 #endif |
| 89 } | 89 } |
| 90 | 90 |
| 91 /* | 91 /* |
| 92 * Getting the assembler to pad our code fragments in templates.S is | 92 * Getting the assembler to pad our code fragments in templates.S is |
| 93 * awkward because we have to output them in data mode, in which the | 93 * awkward because we have to output them in data mode, in which the |
| 94 * assembler wants to output zeroes instead of NOPs for padding. | 94 * assembler wants to output zeroes instead of NOPs for padding. |
| 95 */ | 95 */ |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 assert(errno == EFAULT); | 481 assert(errno == EFAULT); |
| 482 /* The correct range should work, though. */ | 482 /* The correct range should work, though. */ |
| 483 rc = nacl_dyncode_delete(load_addr, sizeof(buf)); | 483 rc = nacl_dyncode_delete(load_addr, sizeof(buf)); |
| 484 assert(rc == 0); | 484 assert(rc == 0); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void check_region_is_filled_with_hlts(const char *data, size_t size) { | 487 void check_region_is_filled_with_hlts(const char *data, size_t size) { |
| 488 #if defined(__i386__) || defined(__x86_64__) | 488 #if defined(__i386__) || defined(__x86_64__) |
| 489 uint8_t halts = 0xf4; /* HLT */ | 489 uint8_t halts = 0xf4; /* HLT */ |
| 490 #elif defined(__arm__) | 490 #elif defined(__arm__) |
| 491 uint32_t halts = NACL_INSTR_HALT_FILL; | 491 uint32_t halts = NACL_INSTR_ARM_HALT_FILL; |
| 492 #else | 492 #else |
| 493 # error "Unknown arch" | 493 # error "Unknown arch" |
| 494 #endif | 494 #endif |
| 495 const char *ptr; | 495 const char *ptr; |
| 496 for (ptr = data; ptr < data + size; ptr += sizeof(halts)) { | 496 for (ptr = data; ptr < data + size; ptr += sizeof(halts)) { |
| 497 assert(memcmp(ptr, &halts, sizeof(halts)) == 0); | 497 assert(memcmp(ptr, &halts, sizeof(halts)) == 0); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 /* | 501 /* |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 597 |
| 598 /* Test again to make sure we didn't run out of space. */ | 598 /* Test again to make sure we didn't run out of space. */ |
| 599 RUN_TEST(test_loading_code); | 599 RUN_TEST(test_loading_code); |
| 600 | 600 |
| 601 return 0; | 601 return 0; |
| 602 } | 602 } |
| 603 | 603 |
| 604 int main() { | 604 int main() { |
| 605 return RunTests(TestMain); | 605 return RunTests(TestMain); |
| 606 } | 606 } |
| OLD | NEW |