devtools: warn about old release notes updates
[dpdk.git] / devtools / check-symbol-maps.sh
1 #! /bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2018 Mellanox Technologies, Ltd
4
5 cd $(dirname $0)/..
6
7 # speed up by ignoring Unicode details
8 export LC_ALL=C
9
10 if [ $# = 0 ] ; then
11     set -- $(find lib drivers -name '*.map')
12 fi
13
14 ret=0
15
16 find_orphan_symbols ()
17 {
18     for map in $@ ; do
19         for sym in $(sed -rn 's,^([^}]*_.*);.*$,\1,p' $map) ; do
20             if echo $sym | grep -q '^per_lcore_' ; then
21                 symsrc=${sym#per_lcore_}
22             elif echo $sym | grep -q '^__rte_.*_trace_' ; then
23                 symsrc=${sym#__}
24             else
25                 symsrc=$sym
26             fi
27             if [ -z "$(grep -rlw $symsrc $(dirname $map) | grep -v $map)" ] ; then
28                 echo "$map: $sym"
29             fi
30         done
31     done
32 }
33
34 orphan_symbols=$(find_orphan_symbols $@)
35 if [ -n "$orphan_symbols" ] ; then
36     echo "Found only in symbol map file:"
37     echo "$orphan_symbols" | sed 's,^,\t,'
38     ret=1
39 fi
40
41 find_duplicate_symbols ()
42 {
43     for map in $@ ; do
44         buildtools/map-list-symbol.sh $map | \
45             sort | uniq -c | grep -v " 1 $map" || true
46     done
47 }
48
49 duplicate_symbols=$(find_duplicate_symbols $@)
50 if [ -n "$duplicate_symbols" ] ; then
51     echo "Found duplicates in symbol map file:"
52     echo "$duplicate_symbols"
53     ret=1
54 fi
55
56 exit $ret