Eric Fiselier | 2d9feb5 | 2015-03-20 22:09:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
Eric Fiselier | 2d9feb5 | 2015-03-20 22:09:29 +0000 | [diff] [blame] | 2 | """ |
| 3 | sym_extract - Extract and output a list of symbols from a shared library. |
| 4 | """ |
| 5 | from argparse import ArgumentParser |
| 6 | from sym_check import extract, util |
| 7 | |
| 8 | |
| 9 | def main(): |
| 10 | parser = ArgumentParser( |
| 11 | description='Extract a list of symbols from a shared library.') |
| 12 | parser.add_argument('library', metavar='shared-lib', type=str, |
| 13 | help='The library to extract symbols from') |
| 14 | parser.add_argument('-o', '--output', dest='output', |
| 15 | help='The output file. stdout is used if not given', |
| 16 | type=str, action='store', default=None) |
| 17 | parser.add_argument('--names-only', dest='names_only', |
| 18 | help='Output only the name of the symbol', |
| 19 | action='store_true', default=False) |
| 20 | args = parser.parse_args() |
| 21 | if args.output is not None: |
| 22 | print('Extracting symbols from %s to %s.' |
| 23 | % (args.library, args.output)) |
| 24 | syms = extract.extract_symbols(args.library) |
| 25 | util.write_syms(syms, out=args.output, names_only=args.names_only) |
| 26 | |
| 27 | |
| 28 | if __name__ == '__main__': |
| 29 | main() |