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

Side by Side Diff: pydir/run-pnacl-sz.py

Issue 1491473002: Subzero. ARM32. Initial sandboxing code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Renames run-pnacl-sz argument. Created 5 years 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 unified diff | Download patch
« no previous file with comments | « pydir/crosstest_generator.py ('k') | pydir/szbuild.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 shellcmd 11 from utils import shellcmd
12 12
13 13
14 def TargetAssemblerFlags(target): 14 def TargetAssemblerFlags(target, sandboxed):
15 # TODO(stichnot): -triple=i686-nacl should be used for a 15 # TODO(stichnot): -triple=i686-nacl should be used for a
16 # sandboxing test. This means there should be an args.sandbox 16 # sandboxing test. This means there should be an args.sandbox
17 # argument that also gets passed through to pnacl-sz. 17 # argument that also gets passed through to pnacl-sz.
18 # TODO(reed kotler). Need to find out exactly we need to 18 # TODO(reed kotler). Need to find out exactly we need to
19 # add here for Mips32. 19 # add here for Mips32.
20 flags = { 'x8632': ['-triple=i686'], 20 flags = { 'x8632': ['-triple=%s' % ('i686' if not sandboxed else 'i686-nacl')] ,
21 'arm32': ['-triple=armv7a', '-mcpu=cortex-a9', '-mattr=+neon'], 21 'arm32': ['-triple=%s' % (
22 'armv7a' if not sandboxed else 'armv7a-nacl'),
23 '-mcpu=cortex-a9', '-mattr=+neon'],
22 'mips32': ['-triple=mipsel' ] } 24 'mips32': ['-triple=mipsel' ] }
23 return flags[target] 25 return flags[target]
24 26
25 27
26 def TargetDisassemblerFlags(target): 28 def TargetDisassemblerFlags(target):
27 flags = { 'x8632': ['-Mintel'], 29 flags = { 'x8632': ['-Mintel'],
28 'arm32': [], 30 'arm32': [],
29 'mips32':[] } 31 'mips32':[] }
30 return flags[target] 32 return flags[target]
31 33
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 argparser.add_argument('--echo-cmd', required=False, 84 argparser.add_argument('--echo-cmd', required=False,
83 action='store_true', 85 action='store_true',
84 help='Trace command that generates ICE instructions') 86 help='Trace command that generates ICE instructions')
85 argparser.add_argument('--tbc', required=False, action='store_true', 87 argparser.add_argument('--tbc', required=False, action='store_true',
86 help='Input is textual bitcode (not .ll)') 88 help='Input is textual bitcode (not .ll)')
87 argparser.add_argument('--expect-fail', required=False, action='store_true', 89 argparser.add_argument('--expect-fail', required=False, action='store_true',
88 help='Negate success of run by using LLVM not') 90 help='Negate success of run by using LLVM not')
89 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, 91 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER,
90 default=[], 92 default=[],
91 help='Remaining arguments are passed to pnacl-sz') 93 help='Remaining arguments are passed to pnacl-sz')
94 argparser.add_argument('--sandbox', required=False, action='store_true',
95 help='Sanboxes the generated code.')
92 96
93 args = argparser.parse_args() 97 args = argparser.parse_args()
94 pnacl_bin_path = args.pnacl_bin_path 98 pnacl_bin_path = args.pnacl_bin_path
95 llfile = args.input 99 llfile = args.input
96 100
97 if args.llvm and args.llvm_source: 101 if args.llvm and args.llvm_source:
98 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") 102 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'")
99 103
100 if args.llvm_source and args.no_local_syms: 104 if args.llvm_source and args.no_local_syms:
101 raise RuntimeError("Can't specify both '--llvm-source' and " + 105 raise RuntimeError("Can't specify both '--llvm-source' and " +
(...skipping 12 matching lines...) Expand all
114 elif not args.llvm_source: 118 elif not args.llvm_source:
115 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|', 119 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
116 os.path.join(pnacl_bin_path, 'pnacl-freeze')] 120 os.path.join(pnacl_bin_path, 'pnacl-freeze')]
117 if not args.no_local_syms: 121 if not args.no_local_syms:
118 cmd += ['--allow-local-symbol-tables'] 122 cmd += ['--allow-local-symbol-tables']
119 cmd += ['|'] 123 cmd += ['|']
120 if args.expect_fail: 124 if args.expect_fail:
121 cmd += [os.path.join(pnacl_bin_path, 'not')] 125 cmd += [os.path.join(pnacl_bin_path, 'not')]
122 cmd += [args.pnacl_sz] 126 cmd += [args.pnacl_sz]
123 cmd += ['--target', args.target] 127 cmd += ['--target', args.target]
128 if args.sandbox:
129 cmd += ['-sandbox']
124 if args.insts: 130 if args.insts:
125 # If the tests are based on '-verbose inst' output, force 131 # If the tests are based on '-verbose inst' output, force
126 # single-threaded translation because dump output does not get 132 # single-threaded translation because dump output does not get
127 # reassembled into order. 133 # reassembled into order.
128 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0'] 134 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0']
129 if not args.llvm_source: 135 if not args.llvm_source:
130 cmd += ['--bitcode-format=pnacl'] 136 cmd += ['--bitcode-format=pnacl']
131 if not args.no_local_syms: 137 if not args.no_local_syms:
132 cmd += ['--allow-local-symbol-tables'] 138 cmd += ['--allow-local-symbol-tables']
133 if args.llvm or args.llvm_source: 139 if args.llvm or args.llvm_source:
134 cmd += ['--build-on-read=0'] 140 cmd += ['--build-on-read=0']
135 else: 141 else:
136 cmd += ['--build-on-read=1'] 142 cmd += ['--build-on-read=1']
137 cmd += ['--filetype=' + args.filetype] 143 cmd += ['--filetype=' + args.filetype]
138 cmd += args.args 144 cmd += args.args
139 if args.llvm_source: 145 if args.llvm_source:
140 cmd += [llfile] 146 cmd += [llfile]
141 asm_temp = None 147 asm_temp = None
142 if args.assemble or args.disassemble: 148 if args.assemble or args.disassemble:
143 # On windows we may need to close the file first before it can be 149 # On windows we may need to close the file first before it can be
144 # re-opened by the other tools, so don't do delete-on-close, 150 # re-opened by the other tools, so don't do delete-on-close,
145 # and instead manually delete. 151 # and instead manually delete.
146 asm_temp = tempfile.NamedTemporaryFile(delete=False) 152 asm_temp = tempfile.NamedTemporaryFile(delete=False)
147 asm_temp.close() 153 asm_temp.close()
148 if args.assemble and args.filetype != 'obj': 154 if args.assemble and args.filetype != 'obj':
149 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] + 155 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] +
150 TargetAssemblerFlags(args.target) + 156 TargetAssemblerFlags(args.target, args.sandbox) +
151 ['-filetype=obj', '-o', asm_temp.name]) 157 ['-filetype=obj', '-o', asm_temp.name])
152 elif asm_temp: 158 elif asm_temp:
153 cmd += ['-o', asm_temp.name] 159 cmd += ['-o', asm_temp.name]
154 if args.disassemble: 160 if args.disassemble:
155 # Show wide instruction encodings, diassemble, and show relocs. 161 # Show wide instruction encodings, diassemble, and show relocs.
156 cmd += (['&&', os.path.join(pnacl_bin_path, 'le32-nacl-objdump')] + 162 cmd += (['&&', os.path.join(pnacl_bin_path, 'le32-nacl-objdump')] +
157 args.dis_flags + 163 args.dis_flags +
158 ['-w', '-d', '-r'] + TargetDisassemblerFlags(args.target) + 164 ['-w', '-d', '-r'] + TargetDisassemblerFlags(args.target) +
159 [asm_temp.name]) 165 [asm_temp.name])
160 166
161 stdout_result = shellcmd(cmd, echo=args.echo_cmd) 167 stdout_result = shellcmd(cmd, echo=args.echo_cmd)
162 if not args.echo_cmd: 168 if not args.echo_cmd:
163 sys.stdout.write(stdout_result) 169 sys.stdout.write(stdout_result)
164 if asm_temp: 170 if asm_temp:
165 os.remove(asm_temp.name) 171 os.remove(asm_temp.name)
166 172
167 if __name__ == '__main__': 173 if __name__ == '__main__':
168 main() 174 main()
OLDNEW
« no previous file with comments | « pydir/crosstest_generator.py ('k') | pydir/szbuild.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698