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 <stdint.h> | 7 #include <stdint.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <inttypes.h> | 9 #include <inttypes.h> |
10 | 10 |
11 int main(void) { | 11 int main(void) { |
12 #if defined(__i386__) || defined(__x86_64__) | 12 #if defined(__i386__) || defined(__x86_64__) |
13 uint8_t code[] __attribute__((aligned(32))) = { 0xc3 /* ret */ }; | 13 uint8_t code[] __attribute__((aligned(32))) = { 0xc3 /* ret */ }; |
14 #elif defined(__arm__) | 14 #elif defined(__arm__) |
15 uint32_t code[] __attribute__((aligned(32))) = { 0xe12fff1e /* BX LR */ }; | 15 uint32_t code[] __attribute__((aligned(32))) = { 0xe12fff1e /* BX LR */ }; |
| 16 #elif defined(__mips__) |
| 17 uint32_t code[] __attribute__((aligned(32))) = { 0x03e00008, /* JR RA */ |
| 18 0 /* NOP */ }; |
16 #else | 19 #else |
17 # error Unknown architecture | 20 # error Unknown architecture |
18 #endif | 21 #endif |
19 | 22 |
20 void (*func)(void); | 23 void (*func)(void); |
21 | 24 |
22 /* Double cast required to stop gcc complaining. */ | 25 /* Double cast required to stop gcc complaining. */ |
23 func = (void (*)(void)) (uintptr_t) code; | 26 func = (void (*)(void)) (uintptr_t) code; |
24 | 27 |
25 fprintf(stderr, "** intended_exit_status=untrusted_sigsegv_or_equivalent\n"); | 28 fprintf(stderr, "** intended_exit_status=untrusted_sigsegv_or_equivalent\n"); |
26 /* This should fault because the data segment should not be executable. */ | 29 /* This should fault because the data segment should not be executable. */ |
27 func(); | 30 func(); |
28 fprintf(stderr, "We're still running. This is bad.\n"); | 31 fprintf(stderr, "We're still running. This is bad.\n"); |
29 return 1; | 32 return 1; |
30 } | 33 } |
OLD | NEW |