summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 22:33:41 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 22:33:41 +0000
commit5214902ed0a0419a8d13954fb233b8953140eb58 (patch)
tree73dc59b1002c4adca7002f8bca0047b395615350
parent4a91d85a0201d32309bf4523a02db44cc292ca12 (diff)
downloadchromium_src-5214902ed0a0419a8d13954fb233b8953140eb58.zip
chromium_src-5214902ed0a0419a8d13954fb233b8953140eb58.tar.gz
chromium_src-5214902ed0a0419a8d13954fb233b8953140eb58.tar.bz2
Revert 97040 - Reserve 1GB at the base address of linux nacl_helper for Native Client.
Use PathService instead of command line flag to obtain path for helper. Adds a nacl_helper_bootstrap executable that implements the actual space reservation. BUG=nativeclient:480 TEST=manual for now Review URL: http://codereview.chromium.org/7599011 TBR=bradchen@google.com Review URL: http://codereview.chromium.org/7669004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97042 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/chrome_paths.cc13
-rw-r--r--chrome/common/chrome_paths.h6
-rw-r--r--chrome/nacl.gypi34
-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
-rwxr-xr-xtools/ld_bfd/ld2
8 files changed, 12 insertions, 123 deletions
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 0758f1e..550b18b 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -52,12 +52,6 @@ const FilePath::CharType kInternalNaClPluginFileName[] =
FILE_PATH_LITERAL("libppGoogleNaClPluginChrome.so");
#endif
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
-// File name of the nacl_helper, Linux only.
-const FilePath::CharType kInternalNaClHelperFileName[] =
- FILE_PATH_LITERAL("nacl_helper_bootstrap");
-#endif
-
} // namespace
namespace chrome {
@@ -240,13 +234,6 @@ bool PathProvider(int key, FilePath* result) {
return false;
cur = cur.Append(kInternalNaClPluginFileName);
break;
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
- case chrome::FILE_NACL_HELPER:
- if (!PathService::Get(base::DIR_MODULE, &cur))
- return false;
- cur = cur.Append(kInternalNaClHelperFileName);
- break;
-#endif
case chrome::FILE_RESOURCES_PACK:
#if defined(OS_MACOSX)
if (base::mac::AmIBundled()) {
diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h
index 4998213..43140ea 100644
--- a/chrome/common/chrome_paths.h
+++ b/chrome/common/chrome_paths.h
@@ -40,7 +40,7 @@ enum {
// using it.
DIR_INTERNAL_PLUGINS, // Directory where internal plugins reside.
DIR_MEDIA_LIBS, // Directory where the Media libraries reside.
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
+#if !defined(OS_MACOSX) && defined(OS_POSIX)
DIR_POLICY_FILES, // Directory for system-wide read-only
// policy files that allow sys-admins
// to set policies for chrome. This directory
@@ -68,10 +68,6 @@ enum {
FILE_FLASH_PLUGIN, // Full path to the internal Flash plugin file.
FILE_PEPPER_FLASH_PLUGIN, // Full path to the pepper Flash plugin file.
FILE_PDF_PLUGIN, // Full path to the internal PDF plugin file.
-
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
- FILE_NACL_HELPER, // Full path to Linux nacl_helper executable.
-#endif
FILE_NACL_PLUGIN, // Full path to the internal NaCl plugin file.
FILE_LIBAVCODEC, // Full path to libavcodec media decoding
// library.
diff --git a/chrome/nacl.gypi b/chrome/nacl.gypi
index b52ab0d..9467359 100644
--- a/chrome/nacl.gypi
+++ b/chrome/nacl.gypi
@@ -144,12 +144,10 @@
},
],
}],
- ['OS=="linux"', {
+ ['OS=="linux" and touchui == 0', {
'targets': [
{
- 'target_name': 'nacl_helper.so',
- # 'executable' will be overridden below when we add the -shared
- # flag; here it prevents gyp from using the --whole-archive flag
+ 'target_name': 'nacl_helper',
'type': 'executable',
'include_dirs': [
'..',
@@ -167,34 +165,6 @@
],
}],
],
- 'link_settings': {
- # NOTE: '-shared' overrides 'executable' above
- 'ldflags': ['-shared',
- '-Wl,--version-script=chrome/nacl/nacl_helper_exports.txt',
- ],
- },
- },
- {
- 'target_name': 'nacl_helper_bootstrap',
- 'type': 'executable',
- 'dependencies': [
- 'nacl_helper.so',
- ],
- 'sources': [
- '../chrome/nacl/nacl_helper_bootstrap_linux.c',
- ],
- # TODO(bradchen): Delete the -B argument when Gold supports
- # -Ttext properly. Until then use ld.bfd.
- 'link_settings': {
- 'ldflags': ['-B', 'tools/ld_bfd',
- # Force text segment at 0x10000 (64KB)
- # The max-page-size option is needed on x86-64 linux
- # where 4K pages are not the default in the BFD linker.
- '-Wl,-Ttext-segment,10000,-z,max-page-size=0x1000',
- # reference nacl_helper as a shared library
- './out/Debug/nacl_helper.so',
- ],
- },
},
],
}],
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
}
diff --git a/tools/ld_bfd/ld b/tools/ld_bfd/ld
index 124f202..5a5d84e 100755
--- a/tools/ld_bfd/ld
+++ b/tools/ld_bfd/ld
@@ -34,8 +34,6 @@ def main():
continue
if arg == "-Wl,--thread-count=4" or arg == "--thread-count=4":
continue
- if arg == "--icf=none":
- continue
args.append(arg)
print("ld_bfd/ld: exec ", args)
sys.exit(subprocess.call(args))