aboutsummaryrefslogtreecommitdiffstats
path: root/build_tools/strip_nonapi
blob: c2262cafacd02e8ff4880ed4c6e92485f95acca4 (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
#!/bin/sh -e

# This script is designed to remove all non-API global symbols from an object
# file. The only global symbols that should be retained are those that belong
# to the official namespace. Unfortunately doing this is platform-specific, as
# the object file manipulation tools are not consistent across platforms.
#
# On platforms where this script does not know what to do, the object file
# will retain non-API global symbols, and this may have unpleasant side effects.
#
# Prefixes that belong to the official namespace are:
#	ast_
#	_ast_
#	__ast_
#	astman_
#	pbx_

FILTER="${GREP} -v -e ^ast_ -e ^_ast_ -e ^__ast_ -e ^astman_ -e ^pbx_"

case "${OSARCH}" in
    linux-gnu)
	nm ${1} | ${GREP} -e " T " | cut -d" " -f3 | ${FILTER} > striplist
	sed -e "s/^/-N /" striplist | xargs ${STRIP} ${1}
	rm -f striplist
	;;
    *)
	;;
esac