blob: a0fbb3e6341a9e9b48a86398fa68d37a6f76d939 [file] [log] [blame]
Eric Fiselier9bf753c2015-03-20 22:09:29 +00001#!/usr/bin/env python
Eric Fiseliereb2ff932016-01-19 21:58:49 +00002#===----------------------------------------------------------------------===##
3#
4# The LLVM Compiler Infrastructure
5#
6# This file is dual licensed under the MIT and the University of Illinois Open
7# Source Licenses. See LICENSE.TXT for details.
8#
9#===----------------------------------------------------------------------===##
Eric Fiselier9bf753c2015-03-20 22:09:29 +000010"""
11sym_extract - Extract and output a list of symbols from a shared library.
12"""
13from argparse import ArgumentParser
14from sym_check import extract, util
15
16
17def main():
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 args = parser.parse_args()
29 if args.output is not None:
30 print('Extracting symbols from %s to %s.'
31 % (args.library, args.output))
32 syms = extract.extract_symbols(args.library)
33 util.write_syms(syms, out=args.output, names_only=args.names_only)
34
35
36if __name__ == '__main__':
37 main()