| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Wrapper script for launching application within the sel_ldr. | 6 """Wrapper script for launching application within the sel_ldr. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import os | 10 import os |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 parser = argparse.ArgumentParser(description=__doc__, epilog=epilog) | 53 parser = argparse.ArgumentParser(description=__doc__, epilog=epilog) |
| 54 parser.add_argument('-v', '--verbose', action='store_true', | 54 parser.add_argument('-v', '--verbose', action='store_true', |
| 55 help='Verbose output') | 55 help='Verbose output') |
| 56 parser.add_argument('-d', '--debug', action='store_true', | 56 parser.add_argument('-d', '--debug', action='store_true', |
| 57 help='Enable debug stub') | 57 help='Enable debug stub') |
| 58 parser.add_argument('-e', '--exceptions', action='store_true', | 58 parser.add_argument('-e', '--exceptions', action='store_true', |
| 59 help='Enable exception handling interface') | 59 help='Enable exception handling interface') |
| 60 parser.add_argument('-p', '--passthrough-environment', action='store_true', | 60 parser.add_argument('-p', '--passthrough-environment', action='store_true', |
| 61 help='Pass environment of host through to nexe') | 61 help='Pass environment of host through to nexe') |
| 62 parser.add_argument('--debug-libs', action='store_true', | 62 parser.add_argument('--debug-libs', action='store_true', |
| 63 help='For dynamic executables, reference debug ' | 63 help='Legacy option, do not use') |
| 64 'libraries rather then release') | 64 parser.add_argument('--config', default='Release', |
| 65 help='Use a particular library configuration (normally ' |
| 66 'Debug or Release)') |
| 65 parser.add_argument('executable', help='executable (.nexe) to run') | 67 parser.add_argument('executable', help='executable (.nexe) to run') |
| 66 parser.add_argument('args', nargs='*', help='argument to pass to exectuable') | 68 parser.add_argument('args', nargs='*', help='argument to pass to exectuable') |
| 67 parser.add_argument('--library-path', | 69 parser.add_argument('--library-path', |
| 68 help='Pass extra library paths') | 70 help='Pass extra library paths') |
| 69 | 71 |
| 70 # To enable bash completion for this command first install optcomplete | 72 # To enable bash completion for this command first install optcomplete |
| 71 # and then add this line to your .bashrc: | 73 # and then add this line to your .bashrc: |
| 72 # complete -F _optcomplete sel_ldr.py | 74 # complete -F _optcomplete sel_ldr.py |
| 73 try: | 75 try: |
| 74 import optcomplete | 76 import optcomplete |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 144 |
| 143 arm_libpath = os.path.join(NACL_SDK_ROOT, 'tools', 'lib', 'arm_trusted') | 145 arm_libpath = os.path.join(NACL_SDK_ROOT, 'tools', 'lib', 'arm_trusted') |
| 144 if not os.path.isdir(arm_libpath): | 146 if not os.path.isdir(arm_libpath): |
| 145 raise Error('Could not find ARM library path: %s' % arm_libpath) | 147 raise Error('Could not find ARM library path: %s' % arm_libpath) |
| 146 qemu = [qemu_bin, '-cpu', 'cortex-a8', '-L', arm_libpath] | 148 qemu = [qemu_bin, '-cpu', 'cortex-a8', '-L', arm_libpath] |
| 147 # '-Q' disables platform qualification, allowing arm binaries to run. | 149 # '-Q' disables platform qualification, allowing arm binaries to run. |
| 148 cmd = qemu + cmd + ['-Q'] | 150 cmd = qemu + cmd + ['-Q'] |
| 149 | 151 |
| 150 if dynamic: | 152 if dynamic: |
| 151 if options.debug_libs: | 153 if options.debug_libs: |
| 152 sdk_lib_dir = os.path.join(NACL_SDK_ROOT, 'lib', | 154 sys.stderr.write('warning: --debug-libs is deprecated (use --config).\n') |
| 153 'glibc_%s' % arch_suffix, 'Debug') | 155 options.config = 'Debug' |
| 154 else: | 156 |
| 155 sdk_lib_dir = os.path.join(NACL_SDK_ROOT, 'lib', | 157 sdk_lib_dir = os.path.join(NACL_SDK_ROOT, 'lib', |
| 156 'glibc_%s' % arch_suffix, 'Release') | 158 'glibc_%s' % arch_suffix, options.config) |
| 157 | 159 |
| 158 if elf_arch == 'x86-64': | 160 if elf_arch == 'x86-64': |
| 159 lib_subdir = 'lib' | 161 lib_subdir = 'lib' |
| 160 tcarch = 'x86' | 162 tcarch = 'x86' |
| 161 tcsubarch = 'x86_64' | 163 tcsubarch = 'x86_64' |
| 162 usr_arch = 'x86_64' | 164 usr_arch = 'x86_64' |
| 163 elif elf_arch == 'arm': | 165 elif elf_arch == 'arm': |
| 164 lib_subdir = 'lib' | 166 lib_subdir = 'lib' |
| 165 tcarch = 'arm' | 167 tcarch = 'arm' |
| 166 tcsubarch = 'arm' | 168 tcsubarch = 'arm' |
| 167 usr_arch = 'arm' | 169 usr_arch = 'arm' |
| 168 elif elf_arch == 'x86-32': | 170 elif elf_arch == 'x86-32': |
| 169 lib_subdir = 'lib32' | 171 lib_subdir = 'lib32' |
| 170 tcarch = 'x86' | 172 tcarch = 'x86' |
| 171 tcsubarch = 'x86_64' | 173 tcsubarch = 'x86_64' |
| 172 usr_arch = 'i686' | 174 usr_arch = 'i686' |
| 173 else: | 175 else: |
| 174 raise Error("Unknown arch: %s" % elf_arch) | 176 raise Error("Unknown arch: %s" % elf_arch) |
| 175 | 177 |
| 176 toolchain = '%s_%s_glibc' % (osname, tcarch) | 178 toolchain = '%s_%s_glibc' % (osname, tcarch) |
| 177 toolchain_dir = os.path.join(NACL_SDK_ROOT, 'toolchain', toolchain) | 179 toolchain_dir = os.path.join(NACL_SDK_ROOT, 'toolchain', toolchain) |
| 178 interp_prefix = os.path.join(toolchain_dir, tcsubarch + '-nacl') | 180 interp_prefix = os.path.join(toolchain_dir, tcsubarch + '-nacl') |
| 179 lib_dir = os.path.join(interp_prefix, lib_subdir) | 181 lib_dir = os.path.join(interp_prefix, lib_subdir) |
| 180 usr_lib_dir = os.path.join(toolchain_dir, usr_arch + '-nacl', 'usr', 'lib') | 182 usr_lib_dir = os.path.join(toolchain_dir, usr_arch + '-nacl', 'usr', 'lib') |
| 181 | 183 |
| 182 libpath = [usr_lib_dir, sdk_lib_dir, lib_dir] | 184 libpath = [usr_lib_dir, sdk_lib_dir, lib_dir] |
| 185 |
| 186 if options.config not in ['Debug', 'Release']: |
| 187 config_fallback = 'Release' |
| 188 if 'Debug' in options.config: |
| 189 config_fallback = 'Debug' |
| 190 libpath.append(os.path.join(NACL_SDK_ROOT, 'lib', |
| 191 'glibc_%s' % arch_suffix, config_fallback)) |
| 192 |
| 183 if options.library_path: | 193 if options.library_path: |
| 184 libpath.extend([os.path.abspath(p) for p | 194 libpath.extend([os.path.abspath(p) for p |
| 185 in options.library_path.split(':')]) | 195 in options.library_path.split(':')]) |
| 186 libpath = ':'.join(libpath) | 196 libpath = ':'.join(libpath) |
| 187 if elf_arch == 'arm': | 197 if elf_arch == 'arm': |
| 188 ldso = os.path.join(SCRIPT_DIR, 'elf_loader_arm.nexe') | 198 ldso = os.path.join(SCRIPT_DIR, 'elf_loader_arm.nexe') |
| 189 cmd.append('-E') | 199 cmd.append('-E') |
| 190 cmd.append('LD_LIBRARY_PATH=%s' % libpath) | 200 cmd.append('LD_LIBRARY_PATH=%s' % libpath) |
| 191 cmd.append(ldso) | 201 cmd.append(ldso) |
| 192 cmd.append('--interp-prefix') | 202 cmd.append('--interp-prefix') |
| (...skipping 13 matching lines...) Expand all Loading... |
| 206 Log(cmd) | 216 Log(cmd) |
| 207 return subprocess.call(cmd) | 217 return subprocess.call(cmd) |
| 208 | 218 |
| 209 | 219 |
| 210 if __name__ == '__main__': | 220 if __name__ == '__main__': |
| 211 try: | 221 try: |
| 212 sys.exit(main(sys.argv[1:])) | 222 sys.exit(main(sys.argv[1:])) |
| 213 except Error as e: | 223 except Error as e: |
| 214 sys.stderr.write(str(e) + '\n') | 224 sys.stderr.write(str(e) + '\n') |
| 215 sys.exit(1) | 225 sys.exit(1) |
| OLD | NEW |