| 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 /* | 7 /* |
| 8 * NaCl Simple/secure ELF loader (NaCl SEL). | 8 * NaCl Simple/secure ELF loader (NaCl SEL). |
| 9 */ | 9 */ |
| 10 #include "native_client/src/include/portability.h" | 10 #include "native_client/src/include/portability.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) { | 478 if (getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) { |
| 479 state.enable_exception_handling = 1; | 479 state.enable_exception_handling = 1; |
| 480 } | 480 } |
| 481 if (state.enable_exception_handling || enable_debug_stub) { | 481 if (state.enable_exception_handling || enable_debug_stub) { |
| 482 #if NACL_WINDOWS | 482 #if NACL_WINDOWS |
| 483 state.attach_debug_exception_handler_func = | 483 state.attach_debug_exception_handler_func = |
| 484 NaClDebugExceptionHandlerStandaloneAttach; | 484 NaClDebugExceptionHandlerStandaloneAttach; |
| 485 #elif NACL_LINUX | 485 #elif NACL_LINUX |
| 486 /* NaCl's signal handler is always enabled on Linux. */ | 486 /* NaCl's signal handler is always enabled on Linux. */ |
| 487 #elif NACL_OSX | 487 #elif NACL_OSX |
| 488 if (!NaClInterceptMachExceptions()) { | |
| 489 fprintf(stderr, "ERROR setting up Mach exception interception.\n"); | |
| 490 return -1; | |
| 491 } | |
| 492 #else | 488 #else |
| 493 # error Unknown host OS | 489 # error Unknown host OS |
| 494 #endif | 490 #endif |
| 495 } | 491 } |
| 496 if (NACL_LINUX) { | 492 if (NACL_LINUX) { |
| 497 handle_signals = 1; | 493 handle_signals = 1; |
| 498 } | 494 } |
| 495 #if NACL_OSX |
| 496 if (!NaClInterceptMachExceptions()) { |
| 497 fprintf(stderr, "ERROR setting up Mach exception interception.\n"); |
| 498 return -1; |
| 499 } |
| 500 #endif |
| 499 | 501 |
| 500 errcode = LOAD_OK; | 502 errcode = LOAD_OK; |
| 501 | 503 |
| 502 /* | 504 /* |
| 503 * in order to report load error to the browser plugin through the | 505 * in order to report load error to the browser plugin through the |
| 504 * secure command channel, we do not immediate jump to cleanup code | 506 * secure command channel, we do not immediate jump to cleanup code |
| 505 * on error. rather, we continue processing (assuming earlier | 507 * on error. rather, we continue processing (assuming earlier |
| 506 * errors do not make it inappropriate) until the secure command | 508 * errors do not make it inappropriate) until the secure command |
| 507 * channel is set up, and then bail out. | 509 * channel is set up, and then bail out. |
| 508 */ | 510 */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 527 errcode = pq_error; | 529 errcode = pq_error; |
| 528 nap->module_load_status = pq_error; | 530 nap->module_load_status = pq_error; |
| 529 fprintf(stderr, "Error while loading \"%s\": %s\n", | 531 fprintf(stderr, "Error while loading \"%s\": %s\n", |
| 530 NULL != nacl_file ? nacl_file | 532 NULL != nacl_file ? nacl_file |
| 531 : "(no file, to-be-supplied-via-RPC)", | 533 : "(no file, to-be-supplied-via-RPC)", |
| 532 NaClErrorString(errcode)); | 534 NaClErrorString(errcode)); |
| 533 } | 535 } |
| 534 } | 536 } |
| 535 | 537 |
| 536 if (handle_signals) { | 538 if (handle_signals) { |
| 539 #if NACL_LINUX |
| 537 NaClSignalHandlerInit(); | 540 NaClSignalHandlerInit(); |
| 541 #endif |
| 538 } else { | 542 } else { |
| 539 /* | 543 /* |
| 540 * Patch the Windows exception dispatcher to be safe in the case | 544 * Patch the Windows exception dispatcher to be safe in the case |
| 541 * of faults inside x86-64 sandboxed code. The sandbox is not | 545 * of faults inside x86-64 sandboxed code. The sandbox is not |
| 542 * secure on 64-bit Windows without this. | 546 * secure on 64-bit Windows without this. |
| 543 */ | 547 */ |
| 544 #if (NACL_WINDOWS && NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && \ | 548 #if (NACL_WINDOWS && NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && \ |
| 545 NACL_BUILD_SUBARCH == 64) | 549 NACL_BUILD_SUBARCH == 64) |
| 546 NaClPatchWindowsExceptionDispatcher(); | 550 NaClPatchWindowsExceptionDispatcher(); |
| 547 #endif | 551 #endif |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 fflush(stdout); | 863 fflush(stdout); |
| 860 | 864 |
| 861 if (handle_signals) NaClSignalHandlerFini(); | 865 if (handle_signals) NaClSignalHandlerFini(); |
| 862 NaClAllModulesFini(); | 866 NaClAllModulesFini(); |
| 863 | 867 |
| 864 NaClExit(ret_code); | 868 NaClExit(ret_code); |
| 865 | 869 |
| 866 /* Unreachable, but having the return prevents a compiler error. */ | 870 /* Unreachable, but having the return prevents a compiler error. */ |
| 867 return ret_code; | 871 return ret_code; |
| 868 } | 872 } |
| OLD | NEW |