| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * TODO(noelallen) split these macros and conditional compiles | 39 * TODO(noelallen) split these macros and conditional compiles |
| 40 * into architecture specific files. Bug #955 | 40 * into architecture specific files. Bug #955 |
| 41 */ | 41 */ |
| 42 | 42 |
| 43 /* Use 4K more than the minimum to allow breakpad to run. */ | 43 /* Use 4K more than the minimum to allow breakpad to run. */ |
| 44 #define SIGNAL_STACK_SIZE (SIGSTKSZ + 4096) | 44 #define SIGNAL_STACK_SIZE (SIGSTKSZ + 4096) |
| 45 #define STACK_GUARD_SIZE NACL_PAGESIZE | 45 #define STACK_GUARD_SIZE NACL_PAGESIZE |
| 46 | 46 |
| 47 static int s_Signals[] = { | 47 static int s_Signals[] = { |
| 48 #if NACL_LINUX | 48 #if NACL_LINUX |
| 49 # if NACL_ARCH(NACL_BUILD_ARCH) != NACL_mips |
| 50 /* This signal does not exist on MIPS. */ |
| 49 SIGSTKFLT, | 51 SIGSTKFLT, |
| 52 # endif |
| 50 NACL_THREAD_SUSPEND_SIGNAL, | 53 NACL_THREAD_SUSPEND_SIGNAL, |
| 51 #endif | 54 #endif |
| 52 SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV | 55 SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 static struct sigaction s_OldActions[NACL_ARRAY_SIZE_UNSAFE(s_Signals)]; | 58 static struct sigaction s_OldActions[NACL_ARRAY_SIZE_UNSAFE(s_Signals)]; |
| 56 | 59 |
| 57 int NaClSignalStackAllocate(void **result) { | 60 int NaClSignalStackAllocate(void **result) { |
| 58 /* | 61 /* |
| 59 * We use mmap() to allocate the signal stack for two reasons: | 62 * We use mmap() to allocate the signal stack for two reasons: |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 * future, we might want to allow the stack to be unwound past the | 256 * future, we might want to allow the stack to be unwound past the |
| 254 * exception frame, and so we might want to treat %rbp differently. | 257 * exception frame, and so we might want to treat %rbp differently. |
| 255 */ | 258 */ |
| 256 regs->rbp = nap->mem_start; | 259 regs->rbp = nap->mem_start; |
| 257 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | 260 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm |
| 258 frame->context.frame_ptr = regs->r11; | 261 frame->context.frame_ptr = regs->r11; |
| 259 regs->lr = kReturnAddr; | 262 regs->lr = kReturnAddr; |
| 260 regs->r0 = context_user_addr; /* Argument 1 */ | 263 regs->r0 = context_user_addr; /* Argument 1 */ |
| 261 regs->prog_ctr = NaClUserToSys(nap, nap->exception_handler); | 264 regs->prog_ctr = NaClUserToSys(nap, nap->exception_handler); |
| 262 regs->stack_ptr = NaClUserToSys(nap, new_stack_ptr); | 265 regs->stack_ptr = NaClUserToSys(nap, new_stack_ptr); |
| 266 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips |
| 267 frame->context.frame_ptr = regs->frame_ptr; |
| 268 regs->return_addr = kReturnAddr; |
| 269 regs->a0 = context_user_addr; |
| 270 regs->prog_ctr = NaClUserToSys(nap, nap->exception_handler); |
| 271 regs->stack_ptr = NaClUserToSys(nap, new_stack_ptr); |
| 263 #else | 272 #else |
| 264 # error Unsupported architecture | 273 # error Unsupported architecture |
| 265 #endif | 274 #endif |
| 266 | 275 |
| 267 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 | 276 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 |
| 268 frame->return_addr = kReturnAddr; | 277 frame->return_addr = kReturnAddr; |
| 269 regs->flags &= ~NACL_X86_DIRECTION_FLAG; | 278 regs->flags &= ~NACL_X86_DIRECTION_FLAG; |
| 270 #endif | 279 #endif |
| 271 | 280 |
| 272 return 1; | 281 return 1; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 421 } |
| 413 if ((sa.sa_flags & SA_SIGINFO) != 0 | 422 if ((sa.sa_flags & SA_SIGINFO) != 0 |
| 414 ? sa.sa_sigaction != NULL | 423 ? sa.sa_sigaction != NULL |
| 415 : (sa.sa_handler != SIG_DFL && sa.sa_handler != SIG_IGN)) { | 424 : (sa.sa_handler != SIG_DFL && sa.sa_handler != SIG_IGN)) { |
| 416 NaClLog(LOG_FATAL, "NaClSignalAssertNoHandlers: " | 425 NaClLog(LOG_FATAL, "NaClSignalAssertNoHandlers: " |
| 417 "A signal handler is registered for signal %d. " | 426 "A signal handler is registered for signal %d. " |
| 418 "Did Breakpad register this?\n", signum); | 427 "Did Breakpad register this?\n", signum); |
| 419 } | 428 } |
| 420 } | 429 } |
| 421 } | 430 } |
| OLD | NEW |