Commit 13a350cc authored by glider@chromium.org's avatar glider@chromium.org

Disable the ASan SEGV handler for NaCl processes on Mac.

Implement __asan_default_options() for the Chrome OSX binary. This function
sets handle_segv=0 iff the binary is executed with --type=nacl-loader.

BUG=323510
TEST=browser_tests pass under ASan on OSX x64
R=cpu@chromium.org, mseaborn@chromium.org

Review URL: https://codereview.chromium.org/96683003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238328 0039d316-1c4b-4281-b951-d872f2087c98
parent 47e58a5f
...@@ -5,7 +5,44 @@ ...@@ -5,7 +5,44 @@
// The entry point for all Mac Chromium processes, including the outer app // The entry point for all Mac Chromium processes, including the outer app
// bundle (browser) and helper app (renderer, plugin, and friends). // bundle (browser) and helper app (renderer, plugin, and friends).
#if defined(ADDRESS_SANITIZER)
#include <crt_externs.h> // for _NSGetArgc, _NSGetArgv
#endif // ADDRESS_SANITIZER
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#if defined(ADDRESS_SANITIZER)
// NaCl requires its own SEGV handler, so we need to add handle_segv=0 to
// ASAN_OPTIONS. This is done by injecting __asan_default_options into the
// executable.
// Because there's no distinct NaCl executable on OSX, we have to look at the
// command line arguments to understand whether the process is a NaCl loader.
static const char kNaClDefaultOptions[] = "handle_segv=0";
static const char kNaClFlag[] = "--type=nacl-loader";
extern "C"
// __asan_default_options() is called at ASan initialization, so it must
// not be instrumented with ASan -- thus the "no_sanitize_address" attribute.
__attribute__((no_sanitize_address))
// The function isn't referenced from the executable itself. Make sure it isn't
// stripped by the linker.
__attribute__((used))
__attribute__((visibility("default")))
const char* __asan_default_options() {
char*** argvp = _NSGetArgv();
int* argcp = _NSGetArgc();
if (!argvp || !argcp) return NULL;
char** argv = *argvp;
int argc = *argcp;
for (int i = 0; i < argc; ++i) {
if (strcmp(argv[i], kNaClFlag) == 0) {
return kNaClDefaultOptions;
}
}
return NULL;
}
#endif // ADDRESS_SANITIZER
extern "C" { extern "C" {
int ChromeMain(int argc, char** argv); int ChromeMain(int argc, char** argv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment