diff options
-rw-r--r-- | chrome/chrome_exe.gypi | 11 | ||||
-rw-r--r-- | chrome/nacl.gypi | 95 | ||||
-rw-r--r-- | chrome/nacl/nacl_fork_delegate_linux.cc | 1 | ||||
-rwxr-xr-x | tools/ld_bfd/ld | 60 |
4 files changed, 110 insertions, 57 deletions
diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index c8a9175..74445a8 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -452,6 +452,17 @@ '../third_party/adobe/flash/flash_player.gyp:flash_player', ], }], + ['OS=="linux"', { + 'conditions': [ + # For now, do not build nacl_helper on ARM or when disable_nacl=1 + ['disable_nacl!=1 and target_arch!="arm"', { + 'dependencies': [ + 'nacl_helper_bootstrap', + 'nacl_helper', + ], + }], + ], + }], ['OS=="mac"', { 'dependencies': [ # On Mac, make sure we've built chrome_dll, which contains all of diff --git a/chrome/nacl.gypi b/chrome/nacl.gypi index 000c5dc..da5f81b 100644 --- a/chrome/nacl.gypi +++ b/chrome/nacl.gypi @@ -236,18 +236,15 @@ ], }, { - 'target_name': 'nacl_helper_bootstrap_raw', - 'type': 'executable', + 'target_name': 'nacl_helper_bootstrap_lib', + 'type': 'static_library', + 'product_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', + 'hard_depencency': 1, 'include_dirs': [ '..', ], 'sources': [ 'nacl/nacl_helper_bootstrap_linux.c', - # We list the linker script here for documentation purposes. - # But even this doesn't make gyp treat it as a dependency, - # so incremental builds won't relink when the script changes. - # TODO(bradnelson): Fix the dependency handling. - 'nacl/nacl_helper_bootstrap_linux.x', ], 'cflags': [ # The tiny standalone bootstrap program is incompatible with @@ -263,27 +260,67 @@ '-fno-pic', '-fno-PIC', '-fno-pie', '-fno-PIE', ], - 'link_settings': { - 'ldflags': [ - # TODO(bradchen): Delete the -B argument when Gold is verified - # to produce good results with our custom linker script. - # Until then use ld.bfd. - '-B', '<(PRODUCT_DIR)/../../tools/ld_bfd', - # This programs is (almost) entirely standalone. It has - # its own startup code, so no crt1.o for it. It is - # statically linked, and on x86 it actually does not use - # libc at all. However, on ARM it needs a few (safe) - # things from libc, so we don't use '-nostdlib' here. - '-static', '-nostartfiles', - # Link with our custom linker script to get out special layout. - '-Wl,--script=<(PRODUCT_DIR)/../../chrome/nacl/nacl_helper_bootstrap_linux.x', - # On x86-64, the default page size with some - # linkers is 2M rather than the real Linux page - # size of 4K. A larger page size is incompatible - # with our custom linker script's special layout. - '-Wl,-z,max-page-size=0x1000', - ], - }, + }, + { + 'target_name': 'nacl_helper_bootstrap_raw', + 'type': 'none', + 'dependencies': [ + 'nacl_helper_bootstrap_lib', + ], + 'actions': [ + { + 'action_name': 'link_with_ld_bfd', + 'variables': { + 'bootstrap_lib': '<(SHARED_INTERMEDIATE_DIR)/chrome/<(STATIC_LIB_PREFIX)nacl_helper_bootstrap_lib<(STATIC_LIB_SUFFIX)', + 'linker_script': 'nacl/nacl_helper_bootstrap_linux.x', + }, + 'inputs': [ + '<(linker_script)', + '<(bootstrap_lib)', + '../tools/ld_bfd/ld', + ], + 'outputs': [ + '<(PRODUCT_DIR)/nacl_helper_bootstrap_raw', + ], + 'message': 'Linking nacl_helper_bootstrap_raw', + 'conditions': [ + ['target_arch=="x64"', { + 'variables': { + 'linker_emulation': 'elf_x86_64', + } + }], + ['target_arch=="ia32"', { + 'variables': { + 'linker_emulation': 'elf_i386', + } + }], + ['target_arch=="arm"', { + 'variables': { + 'linker_emulation': 'armelf_linux_eabi', + } + }], + ], + 'action': ['../tools/ld_bfd/ld', + '-m', '<(linker_emulation)', + # This program is (almost) entirely standalone. It + # has its own startup code, so no crt1.o for it. It is + # statically linked, and on x86 it does not use + # libc at all. However, on ARM it needs a few (safe) + # things from libc. + '-static', + # Link with custom linker script for special layout. + '--script=<(linker_script)', + '-o', '<@(_outputs)', + # On x86-64, the default page size with some + # linkers is 2M rather than the real Linux page + # size of 4K. A larger page size is incompatible + # with our custom linker script's special layout. + '-z', 'max-page-size=0x1000', + '--whole-archive', '<(bootstrap_lib)', + '--no-whole-archive', + ], + } + ], }, { 'target_name': 'nacl_helper_bootstrap', @@ -301,7 +338,7 @@ 'message': 'Munging ELF program header', 'action': ['python', '<@(_inputs)', '<@(_outputs)'] }], - } + }, ], }], ], diff --git a/chrome/nacl/nacl_fork_delegate_linux.cc b/chrome/nacl/nacl_fork_delegate_linux.cc index 1577975..828cb6e 100644 --- a/chrome/nacl/nacl_fork_delegate_linux.cc +++ b/chrome/nacl/nacl_fork_delegate_linux.cc @@ -46,7 +46,6 @@ void NaClForkDelegate::Init(const bool sandboxed, fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); ready_ = false; - return; // disabling nacl_helper for now FilePath helper_exe; FilePath helper_bootstrap_exe; if (PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe) && diff --git a/tools/ld_bfd/ld b/tools/ld_bfd/ld index 124f202..41a9776 100755 --- a/tools/ld_bfd/ld +++ b/tools/ld_bfd/ld @@ -5,39 +5,45 @@ """Wrapper for invoking the BFD loader -A simple script to invoke the bfd loader instead of gold, removing -threading command line options that the bfd loader doesn't support. -Because this script is invoked from gcc via the -B flag, it needs -to be in a file named "ld". +A simple script to invoke the bfd loader instead of gold. +This script is in a filename "ld" so it can be invoked from gcc +via the -B flag. """ - +# TODO(bradchen): Delete this script when Gold supports linker scripts properly. import os import subprocess import sys -# TODO(bradchen): Delete this script when Gold supports -Ttext properly. -# It should be fixed by this patch: -# http://sourceware.org/ml/binutils/2011-07/msg00206.html +def PathTo(fname): + if fname[0] == os.pathsep: + return fname + for p in os.environ["PATH"].split(os.pathsep): + fpath = os.path.join(p, fname) + if os.path.exists(fpath): + return fpath + return fname + +def FindLDBFD(): + cxx = os.getenv("CXX") + if not cxx: + cxx = "gcc" + popen = subprocess.Popen(cxx + " -print-prog-name=ld", + shell=True, + stdout=subprocess.PIPE, + stdin=subprocess.PIPE) + (ld, error) = popen.communicate() + if popen.wait() != 0: + print "Could not find ld:" + error + return "ld" + ld = ld.strip() + ld_bfd = PathTo(ld + ".bfd") + if os.access(ld_bfd, os.X_OK): + return ld_bfd + return ld + def main(): - LD_BFD = "/usr/bin/ld.bfd" - if not (os.path.exists(LD_BFD) and os.access(LD_BFD, os.X_OK)): - # Can't find the BFD loader, so invoke the unmodified argv - args = sys.argv - args[0] = "ld" - print "ld_bfd/ld: using ld" - sys.exit(subprocess.call(args)) - # found the BFD loader, so use it - args = list() - args.append("/usr/bin/ld.bfd") - for arg in sys.argv[1:]: - if arg == "-Wl,--threads" or arg == "--threads": - 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) + args = [FindLDBFD()] + sys.argv[1:] + print("tools/ld_bfd/ld: exec " + ' '.join(args)) sys.exit(subprocess.call(args)) if __name__ == "__main__": |