Chromium Code Reviews| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 fill_int32(data, size, 0xe1a00000); /* NOP (MOV r0, r0) */ | 74 fill_int32(data, size, 0xe1a00000); /* NOP (MOV r0, r0) */ |
| 75 #else | 75 #else |
| 76 # error "Unknown arch" | 76 # error "Unknown arch" |
| 77 #endif | 77 #endif |
| 78 } | 78 } |
| 79 | 79 |
| 80 void fill_hlts(uint8_t *data, size_t size) { | 80 void fill_hlts(uint8_t *data, size_t size) { |
| 81 #if defined(__i386__) || defined(__x86_64__) | 81 #if defined(__i386__) || defined(__x86_64__) |
| 82 memset(data, 0xf4, size); /* HLTs */ | 82 memset(data, 0xf4, size); /* HLTs */ |
| 83 #elif defined(__arm__) | 83 #elif defined(__arm__) |
| 84 fill_int32(data, size, 0xe1266676); /* BKPT 0x6666 */ | 84 fill_int32(data, size, 0xE7FEDEFF); /* UDF #0xEDEF */ |
|
Mark Seaborn
2012/10/18 01:21:39
Ditto
| |
| 85 #else | 85 #else |
| 86 # error "Unknown arch" | 86 # error "Unknown arch" |
| 87 #endif | 87 #endif |
| 88 } | 88 } |
| 89 | 89 |
| 90 /* | 90 /* |
| 91 * Getting the assembler to pad our code fragments in templates.S is | 91 * Getting the assembler to pad our code fragments in templates.S is |
| 92 * awkward because we have to output them in data mode, in which the | 92 * awkward because we have to output them in data mode, in which the |
| 93 * assembler wants to output zeroes instead of NOPs for padding. | 93 * assembler wants to output zeroes instead of NOPs for padding. |
| 94 */ | 94 */ |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 /* The correct range should work, though. */ | 481 /* The correct range should work, though. */ |
| 482 rc = nacl_dyncode_delete(load_addr, sizeof(buf)); | 482 rc = nacl_dyncode_delete(load_addr, sizeof(buf)); |
| 483 assert(rc == 0); | 483 assert(rc == 0); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void check_region_is_filled_with_hlts(const char *data, size_t size) { | 486 void check_region_is_filled_with_hlts(const char *data, size_t size) { |
| 487 uint8_t halts[] = | 487 uint8_t halts[] = |
| 488 #if defined(__i386__) || defined(__x86_64__) | 488 #if defined(__i386__) || defined(__x86_64__) |
| 489 { 0xf4 }; /* HLT */ | 489 { 0xf4 }; /* HLT */ |
| 490 #elif defined(__arm__) | 490 #elif defined(__arm__) |
| 491 { 0x76, 0x66, 0x26, 0xe1 }; /* 0xe1266676 - BKPT 0x6666 */ | 491 { 0xFF, 0xDE, 0xFE, 0xE7 }; /* 0xE7FEDEFF - UDF #0xEDEF */ |
| 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 |