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