Debian Codegraph @

tools/check-symbol-names

raw
1 #!/usr/bin/env bash
2
3 #**************************************************************************
4 #* *
5 #* OCaml *
6 #* *
7 #* Stephen Dolan, University of Cambridge *
8 #* *
9 #* Copyright 2016 Stephen Dolan. *
10 #* *
11 #* All rights reserved. This file is distributed under the terms of *
12 #* the GNU Lesser General Public License version 2.1, with the *
13 #* special exception on linking described in the file LICENSE. *
14 #* *
15 #**************************************************************************
16
17 set -o pipefail
18
19 [ -z "$*" ] && { echo "Usage: $0 libfoo.a" 1>&2; exit 2; }
20
21 nm -A -P "$@" | LC_ALL=C awk '
22 # ignore caml_foo, camlFoo_bar, _caml_foo, _camlFoo_bar
23 $2 ~ /^(\.refptr\.)?(_?__emutls_v\.)?(_?caml[_A-Z])/ { next }
24 # ignore re_foo
25 $2 ~ /^(\.refptr\.)?(_?re_)/ { next }
26 # ignore "extern char **environ"
27 $2 ~ /^(\.refptr\.)?(environ)/ { next }
28 # ignore symbols pulled in by SHGetKnownFolderPath
29 $2 ~ /^\.refptr\.FOLDERID_[a-zA-Z]+/ { next }
30 # ignore local and undefined symbols
31 $3 ~ /^[a-zU]$/ { next }
32 # ignore "main", which should be externally linked
33 $2 ~ /^_?main$/ { next }
34 $2 ~ /^_?wmain$/ { next }
35 # for x86 PIC mode
36 $2 ~ /^__x86.get_pc_thunk./ { next }
37 # for mingw32
38 $2 ~ /^.debug_/ { next }
39 # ignore "__tsan_default_suppressions"
40 $2 ~ /^___?tsan_default_suppressions$/ { next }
41 # ignore custom handlers of volatile reads/writes for TSan
42 $2 ~ /^___?tsan(_unaligned)?_volatile_(read|write)[0-9]+$/ { next }
43 # print the rest
44 { found=1; print $1 " " $2 " " $3 }
45 # fail if there were any results
46 END { exit found ? 1 : 0 }
47 '
48 exit $?