| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Tool for automatically creating .nmf files from .nexe/.pexe executables. | 6 """Tool for automatically creating .nmf files from .nexe/.pexe executables. |
| 7 | 7 |
| 8 As well as creating the nmf file this tool can also find and stage | 8 As well as creating the nmf file this tool can also find and stage |
| 9 any shared libraries dependancies that the executables might have. | 9 any shared libraries dependancies that the executables might have. |
| 10 """ | 10 """ |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 header = f.read(elf_header_size) | 117 header = f.read(elf_header_size) |
| 118 | 118 |
| 119 try: | 119 try: |
| 120 header = struct.unpack(elf_header_format, header) | 120 header = struct.unpack(elf_header_format, header) |
| 121 except struct.error: | 121 except struct.error: |
| 122 raise Error("error parsing elf header: %s" % path) | 122 raise Error("error parsing elf header: %s" % path) |
| 123 e_ident, _, e_machine = header[:3] | 123 e_ident, _, e_machine = header[:3] |
| 124 | 124 |
| 125 elf_magic = '\x7fELF' | 125 elf_magic = '\x7fELF' |
| 126 if e_ident[:4] != elf_magic: | 126 if e_ident[:4] != elf_magic: |
| 127 raise Error('Not a valid NaCL executable: %s' % path) | 127 raise Error('Not a valid NaCl executable: %s' % path) |
| 128 | 128 |
| 129 e_machine_mapping = { | 129 e_machine_mapping = { |
| 130 3 : 'x86-32', | 130 3 : 'x86-32', |
| 131 40 : 'arm', | 131 40 : 'arm', |
| 132 62 : 'x86-64' | 132 62 : 'x86-64' |
| 133 } | 133 } |
| 134 if e_machine not in e_machine_mapping: | 134 if e_machine not in e_machine_mapping: |
| 135 raise Error('Unknown machine type: %s' % e_machine) | 135 raise Error('Unknown machine type: %s' % e_machine) |
| 136 | 136 |
| 137 # Set arch based on the machine type in the elf header | 137 # Set arch based on the machine type in the elf header |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 if __name__ == '__main__': | 760 if __name__ == '__main__': |
| 761 try: | 761 try: |
| 762 rtn = main(sys.argv[1:]) | 762 rtn = main(sys.argv[1:]) |
| 763 except Error, e: | 763 except Error, e: |
| 764 sys.stderr.write('%s: %s\n' % (os.path.basename(__file__), e)) | 764 sys.stderr.write('%s: %s\n' % (os.path.basename(__file__), e)) |
| 765 rtn = 1 | 765 rtn = 1 |
| 766 except KeyboardInterrupt: | 766 except KeyboardInterrupt: |
| 767 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__)) | 767 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__)) |
| 768 rtn = 1 | 768 rtn = 1 |
| 769 sys.exit(rtn) | 769 sys.exit(rtn) |
| OLD | NEW |