| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python |
| 2 # |
| 3 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 """Obtain objdump and gas binaries. |
| 8 |
| 9 Usage: |
| 10 obtain_binutils.py <objdump> <gas> |
| 11 |
| 12 Check out appropriate version of binutils, compile it and |
| 13 copy objdump and gas binaries to specified places. |
| 14 """ |
| 15 |
| 16 import os |
| 17 import shutil |
| 18 import sys |
| 19 |
| 20 CHECKOUT_DIR = '/dev/shm/binutils' |
| 21 |
| 22 BINUTILS_REPO = 'http://git.chromium.org/native_client/nacl-binutils.git' |
| 23 BINUTILS_REVISION = '6993545d5650fa77e75e9ae4b52c5703a53c53cc' |
| 24 |
| 25 # We need specific revision of binutils, and it have to include the |
| 26 # following patches: |
| 27 # Add prefetch_modified - non-canonical encoding of prefetch |
| 28 # |
| 29 # Properly handle data16+rex.w instructions, such as |
| 30 # 66 48 68 01 02 03 04 data32 pushq $0x4030201 |
| 31 # |
| 32 # We are not using head revision because decoder test depends |
| 33 # on precise format of objdump output. |
| 34 |
| 35 |
| 36 def Command(cmd): |
| 37 print |
| 38 print 'Running:', cmd |
| 39 print |
| 40 result = os.system(cmd) |
| 41 if result != 0: |
| 42 print 'Command returned', result |
| 43 exit(result) |
| 44 |
| 45 |
| 46 def main(): |
| 47 if len(sys.argv) != 3: |
| 48 print __doc__ |
| 49 sys.exit(1) |
| 50 |
| 51 if os.path.exists(CHECKOUT_DIR): |
| 52 shutil.rmtree(CHECKOUT_DIR) |
| 53 |
| 54 Command('git clone %s %s' % (BINUTILS_REPO, CHECKOUT_DIR)) |
| 55 |
| 56 try: |
| 57 old_dir = os.getcwd() |
| 58 os.chdir(CHECKOUT_DIR) |
| 59 Command('git checkout %s' % BINUTILS_REVISION) |
| 60 |
| 61 # They both are required to make binutils, |
| 62 # and when they are missing binutils's make |
| 63 # error messages are cryptic. |
| 64 Command('flex --version') |
| 65 Command('bison --version') |
| 66 |
| 67 Command('./configure') |
| 68 Command('make') |
| 69 |
| 70 os.chdir(old_dir) |
| 71 objdump, gas = sys.argv[1:] |
| 72 shutil.copy(os.path.join(CHECKOUT_DIR, 'binutils', 'objdump'), objdump) |
| 73 shutil.copy(os.path.join(CHECKOUT_DIR, 'gas', 'as-new'), gas) |
| 74 finally: |
| 75 shutil.rmtree(CHECKOUT_DIR) |
| 76 |
| 77 print 'ok' |
| 78 |
| 79 |
| 80 if __name__ == '__main__': |
| 81 main() |
| OLD | NEW |