build: replace meson OS detection with variable
[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                 $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
39 done
40
41 # Filter out symbols suffixed with a . for icc
42 for SYM in `awk '{
43         if ($2 != "l" && $4 == ".text.experimental" && !($NF ~ /\.$/)) {
44                 print $NF
45         }
46 }' $DUMPFILE`
47 do
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         }
56 done
57
58 for SYM in `$LIST_SYMBOL -S INTERNAL $MAPFILE |cut -d ' ' -f 3`
59 do
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
70 done
71
72 # Filter out symbols suffixed with a . for icc
73 for SYM in `awk '{
74         if ($2 != "l" && $4 == ".text.internal" && !($NF ~ /\.$/)) {
75                 print $NF
76         }
77 }' $DUMPFILE`
78 do
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         }
87 done
88
89 exit $ret