xref: /f-stack/dpdk/buildtools/check-symbols.sh (revision 2d9fd380)
1#!/bin/sh
2
3# SPDX-License-Identifier: BSD-3-Clause
4
5MAPFILE=$1
6OBJFILE=$2
7
8LIST_SYMBOL=$(dirname $(readlink -f $0))/map-list-symbol.sh
9
10# added check for "make -C test/" usage
11if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
12then
13	exit 0
14fi
15
16if [ -d $MAPFILE ]
17then
18	exit 0
19fi
20
21DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
22trap 'rm -f "$DUMPFILE"' EXIT
23objdump -t $OBJFILE >$DUMPFILE
24
25ret=0
26for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE |cut -d ' ' -f 3`
27do
28	if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
29		! grep -q "\.text\.experimental.*[[:space:]]$SYM$" $DUMPFILE &&
30		$LIST_SYMBOL -s $SYM $MAPFILE | grep -q EXPERIMENTAL
31	then
32		cat >&2 <<- END_OF_MESSAGE
33		$SYM is not flagged as experimental
34		but is listed in version map
35		Please add __rte_experimental to the definition of $SYM
36		END_OF_MESSAGE
37		ret=1
38	fi
39done
40
41# Filter out symbols suffixed with a . for icc
42for SYM in `awk '{
43	if ($2 != "l" && $4 == ".text.experimental" && !($NF ~ /\.$/)) {
44		print $NF
45	}
46}' $DUMPFILE`
47do
48	$LIST_SYMBOL -S EXPERIMENTAL -s $SYM -q $MAPFILE || {
49		cat >&2 <<- END_OF_MESSAGE
50		$SYM is flagged as experimental
51		but is not listed in version map
52		Please add $SYM to the version map
53		END_OF_MESSAGE
54		ret=1
55	}
56done
57
58for SYM in `$LIST_SYMBOL -S INTERNAL $MAPFILE |cut -d ' ' -f 3`
59do
60	if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
61		! grep -q "\.text\.internal.*[[:space:]]$SYM$" $DUMPFILE
62	then
63		cat >&2 <<- END_OF_MESSAGE
64		$SYM is not flagged as internal
65		but is listed in version map
66		Please add __rte_internal to the definition of $SYM
67		END_OF_MESSAGE
68		ret=1
69	fi
70done
71
72# Filter out symbols suffixed with a . for icc
73for SYM in `awk '{
74	if ($2 != "l" && $4 == ".text.internal" && !($NF ~ /\.$/)) {
75		print $NF
76	}
77}' $DUMPFILE`
78do
79	$LIST_SYMBOL -S INTERNAL -s $SYM -q $MAPFILE || {
80		cat >&2 <<- END_OF_MESSAGE
81		$SYM is flagged as internal
82		but is not listed in version map
83		Please add $SYM to the version map
84		END_OF_MESSAGE
85		ret=1
86	}
87done
88
89exit $ret
90