OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
4 import itertools | 4 import itertools |
5 import os | 5 import os |
6 import re | 6 import re |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 | 10 |
11 from utils import FindBaseNaCl, GetObjdumpCmd, shellcmd | 11 from utils import FindBaseNaCl, GetObjdumpCmd, shellcmd |
12 | 12 |
13 | 13 |
14 def TargetAssemblerFlags(target, sandboxed): | 14 def TargetAssemblerFlags(target, sandboxed): |
15 # TODO(reed kotler). Need to find out exactly we need to | 15 # TODO(reed kotler). Need to find out exactly we need to |
16 # add here for Mips32. | 16 # add here for Mips32. |
17 flags = { 'x8632': ['-triple=%s' % ('i686-nacl' if sandboxed else 'i686')], | 17 flags = { 'x8632': ['-triple=%s' % ('i686-nacl' if sandboxed else 'i686')], |
18 'x8664': ['-triple=%s' % ( | 18 'x8664': ['-triple=%s' % ( |
19 'x86_64-nacl' if sandboxed else 'x86_64')], | 19 'x86_64-nacl' if sandboxed else 'x86_64')], |
20 'arm32': ['-triple=%s' % ( | 20 'arm32': ['-triple=%s' % ( |
21 'armv7a-nacl' if sandboxed else 'armv7a'), | 21 'armv7a-nacl' if sandboxed else 'armv7a'), |
22 '-mcpu=cortex-a9', '-mattr=+neon'], | 22 '-mcpu=cortex-a9', '-mattr=+neon'], |
23 'mips32': ['-triple=mipsel' ] } | 23 'mips32': ['-triple=%s' % ( |
| 24 'mipsel-nacl' if sandboxed else 'mipsel'), |
| 25 '-mcpu=mips32'] } |
24 return flags[target] | 26 return flags[target] |
25 | 27 |
26 | 28 |
27 def TargetDisassemblerFlags(target): | 29 def TargetDisassemblerFlags(target): |
28 flags = { 'x8632': ['-Mintel'], | 30 flags = { 'x8632': ['-Mintel'], |
29 'x8664': ['-Mintel'], | 31 'x8664': ['-Mintel'], |
30 'arm32': [], | 32 'arm32': [], |
31 'mips32':[] } | 33 'mips32':[] } |
32 return flags[target] | 34 return flags[target] |
33 | 35 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 output_file_name = asm_temp.name | 199 output_file_name = asm_temp.name |
198 if args.assemble and args.filetype != 'obj': | 200 if args.assemble and args.filetype != 'obj': |
199 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] + | 201 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] + |
200 TargetAssemblerFlags(args.target, args.sandbox) + | 202 TargetAssemblerFlags(args.target, args.sandbox) + |
201 ['-filetype=obj', '-o', output_file_name]) | 203 ['-filetype=obj', '-o', output_file_name]) |
202 elif output_file_name: | 204 elif output_file_name: |
203 cmd += ['-o', output_file_name] | 205 cmd += ['-o', output_file_name] |
204 if args.disassemble: | 206 if args.disassemble: |
205 # Show wide instruction encodings, diassemble, show relocs and | 207 # Show wide instruction encodings, diassemble, show relocs and |
206 # dissasemble zeros. | 208 # dissasemble zeros. |
207 cmd += (['&&', os.path.join(pnacl_bin_path, GetObjdumpCmd())] + | 209 cmd += (['&&', os.path.join(pnacl_bin_path, GetObjdumpCmd(args.target))] + |
208 args.dis_flags + | 210 args.dis_flags + |
209 ['-w', '-d', '-r', '-z'] + TargetDisassemblerFlags(args.target) + | 211 ['-w', '-d', '-r', '-z'] + TargetDisassemblerFlags(args.target) + |
210 [output_file_name]) | 212 [output_file_name]) |
211 | 213 |
212 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 214 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
213 if not args.echo_cmd: | 215 if not args.echo_cmd: |
214 sys.stdout.write(stdout_result) | 216 sys.stdout.write(stdout_result) |
215 if asm_temp and not keep_output_file: | 217 if asm_temp and not keep_output_file: |
216 os.remove(output_file_name) | 218 os.remove(output_file_name) |
217 | 219 |
218 if __name__ == '__main__': | 220 if __name__ == '__main__': |
219 main() | 221 main() |
OLD | NEW |