blob: 5d8953986b283d9ce21d5a12c9811a04c2df2e64 [file] [log] [blame]
Eric Fiselier2d9feb52015-03-20 22:09:29 +00001#!/usr/bin/env python
Eric Fiselier2d9feb52015-03-20 22:09:29 +00002"""
3sym_extract - Extract and output a list of symbols from a shared library.
4"""
5from argparse import ArgumentParser
6from sym_check import extract, util
7
8
9def 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
28if __name__ == '__main__':
29 main()