summaryrefslogtreecommitdiffstats
path: root/chrome/browser/mac
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-07 21:28:41 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-07 21:28:41 +0000
commitc0c7376ea4d7a4dca4c060e9a394317ec80e4db9 (patch)
treedb59cc0ec084ff625d100a8c36cdc895d2abb000 /chrome/browser/mac
parent4a8fdae6d6303a62f4a7e8f4be29f2ff3da74191 (diff)
downloadchromium_src-c0c7376ea4d7a4dca4c060e9a394317ec80e4db9.zip
chromium_src-c0c7376ea4d7a4dca4c060e9a394317ec80e4db9.tar.gz
chromium_src-c0c7376ea4d7a4dca4c060e9a394317ec80e4db9.tar.bz2
Don't use NXArgc or NXArgv. Access them via _NSGetArgc() and _NSGetArgv().
This allows dead code stripping to be turned back on for the main executables and for the NXArgc and NXArgv symbols to be stripped. BUG=139902 Review URL: https://chromiumcodereview.appspot.com/10837149 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mac')
-rw-r--r--chrome/browser/mac/relauncher.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/chrome/browser/mac/relauncher.cc b/chrome/browser/mac/relauncher.cc
index aaaacb9..d028d3e 100644
--- a/chrome/browser/mac/relauncher.cc
+++ b/chrome/browser/mac/relauncher.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +6,7 @@
#include <ApplicationServices/ApplicationServices.h>
#include <AvailabilityMacros.h>
+#include <crt_externs.h>
#include <dlfcn.h>
#include <string.h>
#include <sys/event.h>
@@ -264,22 +265,20 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
// after the separator should be given to the relaunched process; it's also
// important to not treat the path to the relaunched process as a "loose"
// argument. NXArgc and NXArgv are pointers to the original argc and argv as
- // passed to main(), so use those. The typical mechanism to do this is to
- // provide "extern" declarations to access these, but they're only present
- // in the crt1.o start file. This function will be linked into the framework
- // dylib, having no direct access to anything in crt1.o. dlsym to the
- // rescue.
- const int* argcp = static_cast<const int*>(dlsym(RTLD_MAIN_ONLY, "NXArgc"));
+ // passed to main(), so use those. Access them through _NSGetArgc and
+ // _NSGetArgv because NXArgc and NXArgv are normally only available to a
+ // main executable via crt1.o and this code will run from a dylib, and
+ // because of http://crbug.com/139902.
+ const int* argcp = _NSGetArgc();
if (!argcp) {
- LOG(ERROR) << "dlsym NXArgc: " << dlerror();
+ NOTREACHED();
return 1;
}
int argc = *argcp;
- const char* const** argvp =
- static_cast<const char* const**>(dlsym(RTLD_MAIN_ONLY, "NXArgv"));
+ const char* const* const* argvp = _NSGetArgv();
if (!argvp) {
- LOG(ERROR) << "dlsym NXArgv: " << dlerror();
+ NOTREACHED();
return 1;
}
const char* const* argv = *argvp;