Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 # | |
| 6 # This takes three command-line arguments: | |
| 7 # MUNGE-PHDR-PROGRAM file name of program built from | |
| 8 # nacl_helper_bootstrap_munge_phdr.c | |
| 9 # INFILE raw linked ELF file name | |
| 10 # OUTFILE output file name | |
| 11 # | |
| 12 # We just run the MUNGE-PHDR-PROGRAM on a copy of INFILE. | |
| 13 # That modifies the file in place. Then we move it to OUTFILE. | |
| 14 # | |
| 15 # We only have this wrapper script because nacl_helper_bootstrap_munge_phdr.c | |
| 16 # wants to modify a file in place (and it would be a much longer and more | |
| 17 # fragile program if it created a fresh ELF output file instead). | |
| 18 | |
| 19 import optparse | |
|
Mark Seaborn
2011/08/30 20:12:25
Not used.
| |
| 20 import shutil | |
| 21 import subprocess | |
| 22 import sys | |
| 23 | |
| 24 | |
| 25 def Main(argv): | |
| 26 if len(argv) != 4: | |
| 27 print 'Usage: %s MUNGE-PHDR-PROGRAM INFILE OUTFILE' % argv[0] | |
| 28 sys.exit(1) | |
| 29 [prog, munger, infile, outfile] = argv | |
| 30 tmpfile = outfile + '.tmp' | |
| 31 shutil.copy(infile, tmpfile) | |
| 32 result = subprocess.call([munger, tmpfile, '1']) | |
|
Mark Seaborn
2011/08/30 20:12:25
Nit: Maybe do:
segment_num = '1'
result = subproce
| |
| 33 if result != 0: | |
|
Mark Seaborn
2011/08/30 20:12:25
You can use subprocess.check_call(). Then you don
| |
| 34 print '%s failed with %d' % (munger, result) | |
| 35 sys.exit(result) | |
| 36 shutil.move(tmpfile, outfile) | |
| 37 | |
| 38 if __name__ == '__main__': | |
| 39 Main(sys.argv) | |
|
Mark Seaborn
2011/08/30 20:12:25
FWIW, I think it's preferable to do "Main(sys.argv
| |
| OLD | NEW |