| # Copyright 2019 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Extracts an LLD partition from an ELF file.""" |
| parser = argparse.ArgumentParser(description=__doc__) |
| help='Name of partition if not the main partition', |
| help='Path to llvm-objcopy binary', |
| help='Unstripped output file', |
| help='Stripped output file', |
| parser.add_argument('input', help='Input file') |
| args = parser.parse_args() |
| objcopy_args = [args.objcopy] |
| objcopy_args += ['--extract-partition', args.partition] |
| objcopy_args += ['--extract-main-partition'] |
| objcopy_args += [args.input, args.unstripped_output] |
| subprocess.check_call(objcopy_args) |
| args.objcopy, '--strip-all', args.unstripped_output, args.stripped_output |
| subprocess.check_call(objcopy_args) |
| if __name__ == '__main__': |