From c0c7376ea4d7a4dca4c060e9a394317ec80e4db9 Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Tue, 7 Aug 2012 21:28:41 +0000 Subject: 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 --- chrome/browser/mac/relauncher.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'chrome/browser/mac') 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 #include +#include #include #include #include @@ -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(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(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; -- cgit v1.1