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' % ('mipsel-nacl' if sandboxed else 'mipsel') , |
Jim Stichnoth
2016/08/23 14:56:49
80-col
obucinac
2016/09/05 16:55:59
Done.
| |
24 '-mcpu=mips32'] } | |
24 return flags[target] | 25 return flags[target] |
25 | 26 |
26 | 27 |
27 def TargetDisassemblerFlags(target): | 28 def TargetDisassemblerFlags(target): |
28 flags = { 'x8632': ['-Mintel'], | 29 flags = { 'x8632': ['-Mintel'], |
29 'x8664': ['-Mintel'], | 30 'x8664': ['-Mintel'], |
30 'arm32': [], | 31 'arm32': [], |
31 'mips32':[] } | 32 'mips32':[] } |
32 return flags[target] | 33 return flags[target] |
33 | 34 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 asm_temp.close() | 197 asm_temp.close() |
197 output_file_name = asm_temp.name | 198 output_file_name = asm_temp.name |
198 if args.assemble and args.filetype != 'obj': | 199 if args.assemble and args.filetype != 'obj': |
199 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] + | 200 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] + |
200 TargetAssemblerFlags(args.target, args.sandbox) + | 201 TargetAssemblerFlags(args.target, args.sandbox) + |
201 ['-filetype=obj', '-o', output_file_name]) | 202 ['-filetype=obj', '-o', output_file_name]) |
202 elif output_file_name: | 203 elif output_file_name: |
203 cmd += ['-o', output_file_name] | 204 cmd += ['-o', output_file_name] |
204 if args.disassemble: | 205 if args.disassemble: |
205 # Show wide instruction encodings, diassemble, and show relocs. | 206 # Show wide instruction encodings, diassemble, and show relocs. |
206 cmd += (['&&', os.path.join(pnacl_bin_path, GetObjdumpCmd())] + | 207 cmd += (['&&', os.path.join(pnacl_bin_path, GetObjdumpCmd(args.target))] + |
207 args.dis_flags + | 208 args.dis_flags + |
208 ['-w', '-d', '-r'] + TargetDisassemblerFlags(args.target) + | 209 ['-w', '-d', '-r'] + TargetDisassemblerFlags(args.target) + |
209 [output_file_name]) | 210 [output_file_name]) |
210 | 211 |
211 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 212 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
212 if not args.echo_cmd: | 213 if not args.echo_cmd: |
213 sys.stdout.write(stdout_result) | 214 sys.stdout.write(stdout_result) |
214 if asm_temp and not keep_output_file: | 215 if asm_temp and not keep_output_file: |
215 os.remove(output_file_name) | 216 os.remove(output_file_name) |
216 | 217 |
217 if __name__ == '__main__': | 218 if __name__ == '__main__': |
218 main() | 219 main() |
OLD | NEW |