summaryrefslogtreecommitdiffstats
path: root/chrome/nacl
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 23:45:06 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 23:45:06 +0000
commit8e9424b48974b88422d873dab17058f53506437a (patch)
tree2d69e47b5d27dec3025a32ca7ad9870a1dc30ff8 /chrome/nacl
parent3deb30324e1fde3a8374cfbbad7bf32a07abae8b (diff)
downloadchromium_src-8e9424b48974b88422d873dab17058f53506437a.zip
chromium_src-8e9424b48974b88422d873dab17058f53506437a.tar.gz
chromium_src-8e9424b48974b88422d873dab17058f53506437a.tar.bz2
Revert 97056 - Gyp fix for release build.
Reserve 1GB at the base of the address space of linux nacl_helper for Native Client module. Use PathService instead of command line flag to enable helper. Adds a nacl_helper_bootstrap executable that implements the actual space reservation. See http://codereview.chromium.org/7599011 for extended revision history. This is a gyp fix following a revert. TBR=agl,bradnelson BUG=92964, nativeclient:480 TEST=manual for now Review URL: http://codereview.chromium.org/7670011 TBR=bradchen@google.com Review URL: http://codereview.chromium.org/7671011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r--chrome/nacl/nacl_fork_delegate_linux.cc22
-rw-r--r--chrome/nacl/nacl_helper_bootstrap_linux.c24
-rw-r--r--chrome/nacl/nacl_helper_exports.txt10
-rw-r--r--chrome/nacl/nacl_helper_linux.cc24
4 files changed, 9 insertions, 71 deletions
diff --git a/chrome/nacl/nacl_fork_delegate_linux.cc b/chrome/nacl/nacl_fork_delegate_linux.cc
index e5ee01a..794cfda 100644
--- a/chrome/nacl/nacl_fork_delegate_linux.cc
+++ b/chrome/nacl/nacl_fork_delegate_linux.cc
@@ -13,11 +13,9 @@
#include "base/eintr_wrapper.h"
#include "base/logging.h"
#include "base/file_path.h"
-#include "base/path_service.h"
#include "base/process_util.h"
#include "content/common/unix_domain_socket_posix.h"
#include "content/common/zygote_fork_delegate_linux.h"
-#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/nacl_helper_linux.h"
@@ -42,24 +40,18 @@ void NaClForkDelegate::Init(const bool sandboxed,
base::file_handle_mapping_vector fds_to_map;
fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor));
fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor));
- // TODO(bradchen): To make this the default for release builds,
- // remove command line switch.
+ // TODO(bradchen): Before making this the default for release builds,
+ // replace command line switch with PathService::Get().
+ const std::string nacl_zygote_exe =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kNaClLinuxHelper);
ready_ = false;
- const bool use_helper = CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kNaClLinuxHelper);
- FilePath helper_exe;
- if (use_helper && PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe)) {
+ if (nacl_zygote_exe.length() != 0) {
CommandLine::StringVector argv = CommandLine::ForCurrentProcess()->argv();
- argv[0] = helper_exe.value();
+ argv[0] = nacl_zygote_exe;
base::LaunchOptions options;
options.fds_to_remap = &fds_to_map;
options.clone_flags = CLONE_FS | SIGCHLD;
- // LD_BIND_NOW forces non-lazy binding in the dynamic linker, to
- // prevent the linker from trying to look at the text of the nacl_helper
- // program after it has been replaced by the nacl module.
- base::environment_vector env;
- env.push_back(std::make_pair("LD_BIND_NOW", "1"));
- options.environ = &env;
ready_ = base::LaunchProcess(argv, options, NULL);
// parent and error cases are handled below
}
diff --git a/chrome/nacl/nacl_helper_bootstrap_linux.c b/chrome/nacl/nacl_helper_bootstrap_linux.c
deleted file mode 100644
index 7a0ace7..0000000
--- a/chrome/nacl/nacl_helper_bootstrap_linux.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (c) 2011 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.
- *
- * Bootstraping the nacl_helper. This executable reserves the bottom 1G
- * of the address space, then invokes nacl_helper_init. Note that,
- * as the text of this executable will eventually be overwritten by the
- * native_client module, nacl_helper_init must not attempt to return.
- */
-
-#include <stdlib.h>
-
-/* reserve 1GB of space */
-#define ONEGIG (1 << 30)
-char nacl_reserved_space[ONEGIG];
-
-void nacl_helper_init(int argc, char *argv[],
- const char *nacl_reserved_space);
-
-int main(int argc, char *argv[]) {
- nacl_helper_init(argc, argv, nacl_reserved_space);
- abort();
- return 0; // convince the tools I'm sane.
-}
diff --git a/chrome/nacl/nacl_helper_exports.txt b/chrome/nacl/nacl_helper_exports.txt
deleted file mode 100644
index af930c1..0000000
--- a/chrome/nacl/nacl_helper_exports.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# gnu-ld version script for exporting desired symbols from nacl_helper
-#
-
-NACL_HELPER_1_0 {
- global:
- nacl_helper_init;
- nacl_helper_get_1G_address;
- local:
- *;
-};
diff --git a/chrome/nacl/nacl_helper_linux.cc b/chrome/nacl/nacl_helper_linux.cc
index b53cf8d..b943e2b 100644
--- a/chrome/nacl/nacl_helper_linux.cc
+++ b/chrome/nacl/nacl_helper_linux.cc
@@ -116,33 +116,14 @@ void HandleForkRequest(const std::vector<int>& child_fds) {
} // namespace
-static const void* g_nacl_reserved_space = NULL;
-extern "C" __attribute__((visibility("default")))
-const void* nacl_helper_get_1G_address() {
- return g_nacl_reserved_space;
-}
-
-// nacl_helper_init does the real work of this module. It is invoked as
-// a static constructor and never returns, preventing main() from the
-// nacl_helper_bootstrap program from being called.
-//
-// NOTE This routine must not return.
-extern "C" __attribute__((visibility("default")))
-void nacl_helper_init(int argc, char *argv[],
- const char *nacl_reserved_space) {
+int main(int argc, char *argv[]) {
CommandLine::Init(argc, argv);
base::AtExitManager exit_manager;
base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised
std::vector<int> empty; // for SendMsg() calls
g_suid_sandbox_active = (NULL != getenv("SBX_D"));
- g_nacl_reserved_space = nacl_reserved_space;
- if (!nacl_reserved_space) {
- VLOG(1) << "nacl_reserved_space is NULL";
- } else {
- VLOG(1) << "nacl_reserved_space is at "
- << (void *)nacl_reserved_space;
- }
+
// Send the zygote a message to let it know we are ready to help
if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor,
kNaClHelperStartupAck,
@@ -182,5 +163,4 @@ void nacl_helper_init(int argc, char *argv[],
LOG(ERROR) << "*** send() to zygote failed";
}
}
- CHECK(false); // This routine must not return
}