Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 | 2 |
| 3 import argparse | 3 import argparse |
| 4 import os | 4 import os |
| 5 import pipes | 5 import pipes |
| 6 import re | 6 import re |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 from utils import FindBaseNaCl, GetObjcopyCmd, get_sfi_string, shellcmd | 9 from utils import FindBaseNaCl, GetObjcopyCmd, get_sfi_string, shellcmd |
| 10 | 10 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 help='Generate code for specified target.') | 96 help='Generate code for specified target.') |
| 97 argparser.add_argument('--verbose', '-v', dest='verbose', | 97 argparser.add_argument('--verbose', '-v', dest='verbose', |
| 98 action='store_true', | 98 action='store_true', |
| 99 help='Display some extra debugging output') | 99 help='Display some extra debugging output') |
| 100 argparser.add_argument('--sz', dest='sz_args', action='append', default=[], | 100 argparser.add_argument('--sz', dest='sz_args', action='append', default=[], |
| 101 help='Extra arguments for Subzero') | 101 help='Extra arguments for Subzero') |
| 102 argparser.add_argument('--llc', dest='llc_args', action='append', | 102 argparser.add_argument('--llc', dest='llc_args', action='append', |
| 103 default=[], help='Extra arguments for llc') | 103 default=[], help='Extra arguments for llc') |
| 104 argparser.add_argument('--no-sz', dest='nosz', action='store_true', | 104 argparser.add_argument('--no-sz', dest='nosz', action='store_true', |
| 105 help='Run only post-Subzero build steps') | 105 help='Run only post-Subzero build steps') |
| 106 argparser.add_argument('--fsanitize-address', dest='asan', | |
| 107 action='store_true', | |
| 108 help='Instrument with AddressSanitizer') | |
| 106 | 109 |
| 107 def LinkSandbox(objs, exe, target, verbose=True): | 110 def LinkSandbox(objs, exe, target, verbose=True): |
| 108 assert target in ('x8632', 'x8664', 'arm32'), \ | 111 assert target in ('x8632', 'x8664', 'arm32'), \ |
| 109 '-sandbox is not available for %s' % target | 112 '-sandbox is not available for %s' % target |
| 110 nacl_root = FindBaseNaCl() | 113 nacl_root = FindBaseNaCl() |
| 111 gold = ('{root}/toolchain/linux_x86/pnacl_newlib_raw/bin/' + | 114 gold = ('{root}/toolchain/linux_x86/pnacl_newlib_raw/bin/' + |
| 112 'le32-nacl-ld.gold').format(root=nacl_root) | 115 'le32-nacl-ld.gold').format(root=nacl_root) |
| 113 target_lib_dir = { | 116 target_lib_dir = { |
| 114 'arm32': 'arm', | 117 'arm32': 'arm', |
| 115 'x8632': 'x86-32', | 118 'x8632': 'x86-32', |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 --install=toolchain/linux_x86/pnacl_newlib_raw | 259 --install=toolchain/linux_x86/pnacl_newlib_raw |
| 257 """ | 260 """ |
| 258 argparser = argparse.ArgumentParser( | 261 argparser = argparse.ArgumentParser( |
| 259 description=' ' + main.__doc__, | 262 description=' ' + main.__doc__, |
| 260 formatter_class=argparse.RawTextHelpFormatter) | 263 formatter_class=argparse.RawTextHelpFormatter) |
| 261 AddOptionalArgs(argparser) | 264 AddOptionalArgs(argparser) |
| 262 argparser.add_argument('pexe', help='Finalized pexe to translate') | 265 argparser.add_argument('pexe', help='Finalized pexe to translate') |
| 263 args = argparser.parse_args() | 266 args = argparser.parse_args() |
| 264 pexe = args.pexe | 267 pexe = args.pexe |
| 265 exe = args.output | 268 exe = args.output |
| 269 if args.asan: | |
| 270 if args.sandbox or args.nonsfi: | |
| 271 print 'Can only use AddressSanitizer with a native build' | |
| 272 exit() | |
| 273 if not '-fsanitize-address' in args.sz_args: | |
| 274 args.sz_args.append('-fsanitize-address') | |
|
Jim Stichnoth
2016/06/15 05:21:16
I think you still want to append -fsanitize-addres
tlively
2016/06/15 16:32:00
Done.
| |
| 266 ProcessPexe(args, pexe, exe) | 275 ProcessPexe(args, pexe, exe) |
| 267 | 276 |
| 268 def ProcessPexe(args, pexe, exe): | 277 def ProcessPexe(args, pexe, exe): |
| 269 [pexe_base, ext] = os.path.splitext(pexe) | 278 [pexe_base, ext] = os.path.splitext(pexe) |
| 270 if ext != '.pexe': | 279 if ext != '.pexe': |
| 271 pexe_base = pexe | 280 pexe_base = pexe |
| 272 pexe_base_unescaped = pexe_base | 281 pexe_base_unescaped = pexe_base |
| 273 pexe_base = pipes.quote(pexe_base) | 282 pexe_base = pipes.quote(pexe_base) |
| 274 pexe = pipes.quote(pexe) | 283 pexe = pipes.quote(pexe) |
| 275 | 284 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 start=get_sfi_string(args, '_start', '_start', | 448 start=get_sfi_string(args, '_start', '_start', |
| 440 '_user_start')), | 449 '_user_start')), |
| 441 echo=args.verbose) | 450 echo=args.verbose) |
| 442 | 451 |
| 443 # Run the linker regardless of hybrid mode. | 452 # Run the linker regardless of hybrid mode. |
| 444 if args.sandbox: | 453 if args.sandbox: |
| 445 LinkSandbox([obj_partial], exe, args.target, args.verbose) | 454 LinkSandbox([obj_partial], exe, args.target, args.verbose) |
| 446 elif args.nonsfi: | 455 elif args.nonsfi: |
| 447 LinkNonsfi([obj_partial], exe, args.target, args.verbose) | 456 LinkNonsfi([obj_partial], exe, args.target, args.verbose) |
| 448 else: | 457 else: |
| 449 LinkNative([obj_partial], exe, args.target, args.verbose) | 458 objs = [obj_partial] |
| 459 if args.asan: | |
| 460 objs.append( | |
| 461 ('{root}/toolchain_build/src/subzero/build/runtime/' + | |
| 462 'szrt_asan_{target}.o').format(root=nacl_root, | |
| 463 target=args.target)) | |
| 464 LinkNative(objs, exe, args.target, args.verbose) | |
| 450 | 465 |
| 451 # Put the extra verbose printing at the end. | 466 # Put the extra verbose printing at the end. |
| 452 if args.verbose and hybrid: | 467 if args.verbose and hybrid: |
| 453 print 'include={regex}'.format(regex=re_include_str) | 468 print 'include={regex}'.format(regex=re_include_str) |
| 454 print 'exclude={regex}'.format(regex=re_exclude_str) | 469 print 'exclude={regex}'.format(regex=re_exclude_str) |
| 455 print 'default_match={dm}'.format(dm=default_match) | 470 print 'default_match={dm}'.format(dm=default_match) |
| 456 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 471 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
| 457 | 472 |
| 458 if __name__ == '__main__': | 473 if __name__ == '__main__': |
| 459 main() | 474 main() |
| OLD | NEW |