-
Notifications
You must be signed in to change notification settings - Fork 3
/
shlibvischeck-common
executable file
·60 lines (51 loc) · 2.27 KB
/
shlibvischeck-common
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python3
# The MIT License (MIT)
#
# Copyright 2020 Yury Gribov
#
# Use of this source code is governed by MIT license that can be
# found in the LICENSE.txt file.
# Analyzes difference between public and binary interfaces in package files.
# Command-line equivalent:
# $ read_header_api --cflags="-I/usr/include -I$AUDIT_INSTALL/include -I/usr/lib/llvm-5.0/lib/clang/5.0.0/include" $AUDIT_INSTALL/include/*.h > public_api.txt
# $ read_binary_api --permissive $AUDIT_INSTALL/lib/*.so* > exported_api.txt
# $ comm -13 public_api.txt exported_api.txt
import os
import os.path
import argparse
import shlibvischeck.common.error as e
from shlibvischeck.analysis.package import *
def main():
me = os.path.basename(__file__)
e.set_basename(me)
e.set_throw_on_error()
parser = argparse.ArgumentParser(description="Analyzes difference between public and binary interfaces in package files.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""\
Examples:
$ {0} *.h *.so*
""".format(me))
parser.add_argument('--verbose', '-v',
help="Print diagnostic info.",
action='count', default=0)
parser.add_argument('--permissive', '-p',
help="Ignore dummy symbols introduced by ld (_edata, __bss_start, etc.) "
"and libgcc (_init, _fini).",
dest='permissive', action='store_true', default=False)
parser.add_argument('--no-permissive',
help="Disable --permissive (default).",
dest='permissive', action='store_false')
parser.add_argument('--cflags', '-f',
help="Compiler flags to use when parsing headers (may be specified more than once for separate trials).",
action='append', default=[])
parser.add_argument('rest',
nargs=argparse.REMAINDER, default=[])
args = parser.parse_args()
spurious_syms = analyze_package('<unknown>', args.rest, args.cflags, args.permissive, args.verbose)
if spurious_syms:
print("The following exported symbols are private:\n %s"
% ('\n '.join(spurious_syms)))
else:
print("No private exports")
if __name__ == '__main__':
main()