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