blob: a8afe539d5185b7370d4eab3071d60946ac1befd (
plain)
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
|
#!/usr/bin/env bash
#**************************************************************************
#* *
#* OCaml *
#* *
#* Stephen Dolan, University of Cambridge *
#* *
#* Copyright 2016 Stephen Dolan. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
set -o pipefail
[ -z "$*" ] && { echo "Usage: $0 libfoo.a" 1>&2; exit 2; }
nm -A -P "$@" | LC_ALL=C awk '
# ignore caml_foo, camlFoo_bar, _caml_foo, _camlFoo_bar
$2 ~ /^(_?caml[_A-Z])/ { next }
# ignore local and undefined symbols
$3 ~ /^[a-zU]$/ { next }
# ignore "main", which should be externally linked
$2 ~ /^_?main$/ { next }
$2 ~ /^_?wmain$/ { next }
# for x86 PIC mode
$2 ~ /^__x86.get_pc_thunk./ { next }
# for mingw32
$2 ~ /^.debug_/ { next }
# windows unicode support
$2 ~ /^_win_multi_byte_to_wide_char$/ { next }
$2 ~ /^_win_wide_char_to_multi_byte$/ { next }
# print the rest
{ found=1; print $1 " " $2 " " $3 }
# fail if there were any results
END { exit found ? 1 : 0 }
'
exit $?
|