2 #===----------------------------------------------------------------------===##
4 # The LLVM Compiler Infrastructure
6 # This file is dual licensed under the MIT and the University of Illinois Open
7 # Source Licenses. See LICENSE.TXT for details.
9 #===----------------------------------------------------------------------===##
11 sym_extract - Extract and output a list of symbols from a shared library.
13 from argparse import ArgumentParser
14 from sym_check import extract, util
18 parser = ArgumentParser(
19 description='Extract a list of symbols from a shared library.')
20 parser.add_argument('library', metavar='shared-lib', type=str,
21 help='The library to extract symbols from')
22 parser.add_argument('-o', '--output', dest='output',
23 help='The output file. stdout is used if not given',
24 type=str, action='store', default=None)
25 parser.add_argument('--names-only', dest='names_only',
26 help='Output only the name of the symbol',
27 action='store_true', default=False)
28 parser.add_argument('--only-stdlib-symbols', dest='only_stdlib',
29 help="Filter all symbols not related to the stdlib",
30 action='store_true', default=False)
31 args = parser.parse_args()
32 if args.output is not None:
33 print('Extracting symbols from %s to %s.'
34 % (args.library, args.output))
35 syms = extract.extract_symbols(args.library)
37 syms, other_syms = util.filter_stdlib_symbols(syms)
38 util.write_syms(syms, out=args.output, names_only=args.names_only)
41 if __name__ == '__main__':