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

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, 7 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..90c8a3cb5dacebbea75227fe3eff9ba03726b1ac 100755
--- a/native_client_sdk/src/tools/sel_ldr.py
+++ b/native_client_sdk/src/tools/sel_ldr.py
@@ -32,6 +32,22 @@ def Log(msg):
Log.verbose = False
+def FindQemu():
+ 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)]
+ 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
+ return qemu_bin
+
+
def main(argv):
usage = 'Usage: %prog [options] <.nexe>'
epilog = 'Example: sel_ldr.py my_nexe.nexe'
@@ -69,8 +85,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 +115,19 @@ def main(argv):
if not options.verbose:
cmd += ['-l', os.devnull]
+ if arch == 'arm':
+ # Use the QEMU arm emulator if available.
+ qemu_bin = FindQemu()
+ 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/).')
+
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