| 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 shutil | 5 import shutil |
| 6 import tempfile | 6 import tempfile |
| 7 from utils import shellcmd | 7 from utils import shellcmd |
| 8 from utils import FindBaseNaCl | 8 from utils import FindBaseNaCl |
| 9 | 9 |
| 10 def Translate(ll_files, extra_args, obj, verbose): | 10 def Translate(ll_files, extra_args, obj, verbose): |
| 11 """Translate a set of input bitcode files into a single object file. | 11 """Translate a set of input bitcode files into a single object file. |
| 12 | 12 |
| 13 Use pnacl-llc to translate textual bitcode input ll_files into object file | 13 Use pnacl-llc to translate textual bitcode input ll_files into object file |
| 14 obj, using extra_args as the architectural flags. | 14 obj, using extra_args as the architectural flags. |
| 15 """ | 15 """ |
| 16 shellcmd(['cat'] + ll_files + ['|', | 16 shellcmd(['cat'] + ll_files + ['|', |
| 17 'pnacl-llc', | 17 'pnacl-llc', |
| 18 '-externalize', | 18 '-externalize', |
| 19 '-function-sections', |
| 20 '-O2', |
| 19 '-filetype=obj', | 21 '-filetype=obj', |
| 20 '-bitcode-format=llvm', | 22 '-bitcode-format=llvm', |
| 21 '-o', obj | 23 '-o', obj |
| 22 ] + extra_args, echo=verbose) | 24 ] + extra_args, echo=verbose) |
| 23 shellcmd(['objcopy', | 25 shellcmd(['objcopy', |
| 24 '--localize-symbol=nacl_tp_tdb_offset', | 26 '--localize-symbol=nacl_tp_tdb_offset', |
| 25 '--localize-symbol=nacl_tp_tls_offset', | 27 '--localize-symbol=nacl_tp_tls_offset', |
| 26 obj | 28 obj |
| 27 ], echo=verbose) | 29 ], echo=verbose) |
| 28 | 30 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 args.verbose) | 84 args.verbose) |
| 83 finally: | 85 finally: |
| 84 try: | 86 try: |
| 85 shutil.rmtree(tempdir) | 87 shutil.rmtree(tempdir) |
| 86 except OSError as exc: | 88 except OSError as exc: |
| 87 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory | 89 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory |
| 88 raise # re-raise exception | 90 raise # re-raise exception |
| 89 | 91 |
| 90 if __name__ == '__main__': | 92 if __name__ == '__main__': |
| 91 main() | 93 main() |
| OLD | NEW |