Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: native_client_sdk/src/tools/sel_ldr.py

Issue 262753005: Allows sel_ldr.py to run arm binaries through qemu-arm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/tools/sel_ldr.py
diff --git a/native_client_sdk/src/tools/sel_ldr.py b/native_client_sdk/src/tools/sel_ldr.py
index 911a853f91e228698060eb6492b5959e14073321..e628d7f23e0739474c7fa72e5b77065e87be517b 100755
--- a/native_client_sdk/src/tools/sel_ldr.py
+++ b/native_client_sdk/src/tools/sel_ldr.py
@@ -11,10 +11,12 @@ import os
import subprocess
import sys
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+sys.path.append(SCRIPT_DIR)
Sam Clegg 2014/05/01 19:19:10 This is the default for python normally. I think
cdonner 2014/05/02 17:58:06 Reverted.
+
import create_nmf
import getos
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
NACL_SDK_ROOT = os.path.dirname(SCRIPT_DIR)
if sys.version_info < (2, 6, 0):
@@ -69,8 +71,8 @@ def main(argv):
arch, dynamic = create_nmf.ParseElfHeader(nexe)
- if arch == 'arm':
- raise Error('Cannot run ARM executables under sel_ldr')
+ if arch == 'arm' and osname != 'linux':
+ raise Error('Cannot run ARM executables under sel_ldr on ' + osname)
arch_suffix = arch.replace('-', '_')
@@ -99,6 +101,30 @@ def main(argv):
if not options.verbose:
cmd += ['-l', os.devnull]
+ if arch == 'arm':
+ # Use the QEMU arm emulator if available.
+ qemu_locations = [os.path.join(SCRIPT_DIR, 'qemu_arm'),
+ os.path.join(SCRIPT_DIR, 'qemu-arm')]
+ qemu_locations += [os.path.join(path, 'qemu_arm')
+ for path in os.environ["PATH"].split(os.pathsep)]
Sam Clegg 2014/05/01 19:19:10 Can probably drop these two lines? Isn't it alway
cdonner 2014/05/02 17:58:06 google3 has qemu_arm, but I noticed that the nativ
+ qemu_locations += [os.path.join(path, 'qemu-arm')
+ for path in os.environ["PATH"].split(os.pathsep)]
+ # See if qemu is in any of these locations.
+ qemu_bin = None
+ for loc in qemu_locations:
+ if os.path.isfile(loc) and os.access(loc, os.X_OK):
+ qemu_bin = loc
+ break
+ if qemu_bin:
+ qemu = [qemu_bin, '-cpu', 'cortex-a8', '-L',
+ os.path.abspath(os.path.join(NACL_SDK_ROOT, 'toolchain',
+ 'linux_arm_trusted'))]
+ # '-Q' disables platform qualification, allowing arm binaries to run.
+ cmd = qemu + cmd + ['-Q']
+ else:
+ raise Error('Cannot run ARM executables under sel_ldr without an emulator'
+ '. Try installing QEMU (http://wiki.qemu.org/).')
Sam Clegg 2014/05/01 19:19:10 How about a separate FindQemu() function?
cdonner 2014/05/02 17:58:06 Done.
+
if dynamic:
if options.debug_libs:
libpath = os.path.join(NACL_SDK_ROOT, 'lib',
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698