| 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 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 cmd += [llfile] | 105 cmd += [llfile] |
| 106 asm_temp = None | 106 asm_temp = None |
| 107 if args.assemble or args.disassemble: | 107 if args.assemble or args.disassemble: |
| 108 # On windows we may need to close the file first before it can be | 108 # On windows we may need to close the file first before it can be |
| 109 # re-opened by the other tools, so don't do delete-on-close, | 109 # re-opened by the other tools, so don't do delete-on-close, |
| 110 # and instead manually delete. | 110 # and instead manually delete. |
| 111 asm_temp = tempfile.NamedTemporaryFile(delete=False) | 111 asm_temp = tempfile.NamedTemporaryFile(delete=False) |
| 112 asm_temp.close() | 112 asm_temp.close() |
| 113 if args.assemble and args.filetype != 'obj': | 113 if args.assemble and args.filetype != 'obj': |
| 114 cmd += ['|', os.path.join(llvm_bin_path, 'llvm-mc'), | 114 cmd += ['|', os.path.join(llvm_bin_path, 'llvm-mc'), |
| 115 '-triple=i686-none-nacl', | 115 # TODO(stichnot): -triple=i686-nacl should be used for a |
| 116 # sandboxing test. This means there should be an args.sandbox |
| 117 # argument that also gets passed through to pnacl-sz. |
| 118 '-triple=i686', |
| 116 '-filetype=obj', '-o', asm_temp.name] | 119 '-filetype=obj', '-o', asm_temp.name] |
| 117 elif asm_temp: | 120 elif asm_temp: |
| 118 cmd += ['-o', asm_temp.name] | 121 cmd += ['-o', asm_temp.name] |
| 119 if args.disassemble: | 122 if args.disassemble: |
| 120 # Show wide instruction encodings, diassemble, and show relocs. | 123 # Show wide instruction encodings, diassemble, and show relocs. |
| 121 cmd += (['&&', os.path.join(binutils_bin_path, 'objdump')] + | 124 cmd += (['&&', os.path.join(binutils_bin_path, 'objdump')] + |
| 122 args.dis_flags + | 125 args.dis_flags + |
| 123 ['-w', '-d', '-r', '-Mintel', asm_temp.name]) | 126 ['-w', '-d', '-r', '-Mintel', asm_temp.name]) |
| 124 | 127 |
| 125 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 128 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
| 126 if not args.echo_cmd: | 129 if not args.echo_cmd: |
| 127 sys.stdout.write(stdout_result) | 130 sys.stdout.write(stdout_result) |
| 128 if asm_temp: | 131 if asm_temp: |
| 129 os.remove(asm_temp.name) | 132 os.remove(asm_temp.name) |
| 130 | 133 |
| 131 if __name__ == '__main__': | 134 if __name__ == '__main__': |
| 132 main() | 135 main() |
| OLD | NEW |