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> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 # elif defined(__x86_64__) | 69 # elif defined(__x86_64__) |
70 "naclrestsp $recovery_stack - 8, %r15\n" | 70 "naclrestsp $recovery_stack - 8, %r15\n" |
71 "jmp error_exit\n" | 71 "jmp error_exit\n" |
72 # endif | 72 # endif |
73 ".popsection\n"); | 73 ".popsection\n"); |
74 | 74 |
75 void error_exit(void) { | 75 void error_exit(void) { |
76 _exit(1); | 76 _exit(1); |
77 } | 77 } |
78 | 78 |
| 79 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips |
| 80 |
| 81 char recovery_stack[0x1000] __attribute__((aligned(8))); |
| 82 |
| 83 void bad_stack_exception_handler(struct NaClExceptionContext *context); |
| 84 __asm__(".pushsection .text, \"ax\", @progbits\n" |
| 85 ".global bad_stack_exception_handler\n" |
| 86 "bad_stack_exception_handler:\n" |
| 87 "lui $t9, %hi(recovery_stack)\n" |
| 88 "addiu $sp, $t9, %lo(recovery_stack)\n" |
| 89 "and $sp, $sp, $t7\n" |
| 90 "j error_exit\n" |
| 91 "nop\n" |
| 92 ".popsection\n"); |
| 93 |
| 94 void error_exit() { |
| 95 _exit(1); |
| 96 } |
| 97 |
79 #else | 98 #else |
80 | 99 |
81 /* TODO(mseaborn): Implement a stack switcher, like the one above, for ARM. */ | 100 /* TODO(mseaborn): Implement a stack switcher, like the one above, for ARM. */ |
82 void bad_stack_exception_handler(struct NaClExceptionContext *context) { | 101 void bad_stack_exception_handler(struct NaClExceptionContext *context) { |
83 _exit(1); | 102 _exit(1); |
84 } | 103 } |
85 | 104 |
86 #endif | 105 #endif |
87 | 106 |
88 | 107 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 TRY_TEST(test_bad_handler); | 240 TRY_TEST(test_bad_handler); |
222 TRY_TEST(test_stack_outside_sandbox); | 241 TRY_TEST(test_stack_outside_sandbox); |
223 TRY_TEST(test_stack_in_rwdata); | 242 TRY_TEST(test_stack_in_rwdata); |
224 TRY_TEST(test_stack_in_rodata); | 243 TRY_TEST(test_stack_in_rodata); |
225 TRY_TEST(test_stack_in_code); | 244 TRY_TEST(test_stack_in_code); |
226 TRY_TEST(test_crash_in_syscall); | 245 TRY_TEST(test_crash_in_syscall); |
227 | 246 |
228 fprintf(stderr, "Error: Unknown test: \"%s\"\n", argv[1]); | 247 fprintf(stderr, "Error: Unknown test: \"%s\"\n", argv[1]); |
229 return 1; | 248 return 1; |
230 } | 249 } |
OLD | NEW |