2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright(c) 2018 Neil Horman <nhorman@tuxdriver.com>
11 # Initialize our variables
12 BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
14 # Anything that starts with + or -, followed by an a
15 # and ends in the string .map is the name of our map file
16 # This may appear multiple times in a patch if multiple
17 # map files are altered, and all section/symbol names
18 # appearing between a triggering of this rule and the
19 # next trigger of this rule are associated with this file
20 /[-+] a\/.*\.map/ {map=$2; in_map=1}
22 # Same pattern as above, only it matches on anything that
23 # does not end in 'map', indicating we have left the map chunk.
24 # When we hit this, turn off the in_map variable, which
25 # supresses the subordonate rules below
26 /[-+] a\/.*\.[^map]/ {in_map=0}
28 # Triggering this rule, which starts a line and ends it
29 # with a { identifies a versioned section. The section name is
30 # the rest of the line with the + and { symbols remvoed.
31 # Triggering this rule sets in_sec to 1, which actives the
36 sec=$(NF-1); in_sec=1;
40 # This rule idenfies the end of a section, and disables the
44 # This rule matches on a + followed by any characters except a :
45 # (which denotes a global vs local segment), and ends with a ;.
46 # The semicolon is removed and the symbol is printed with its
47 # association file name and version section, along with an
48 # indicator that the symbol is a new addition. Note this rule
49 # only works if we have found a version section in the rule
50 # above (hence the in_sec check) And found a map file (the
51 # in_map check). If we are not in a map chunk, do nothing. If
52 # we are in a map chunk but not a section chunk, record it as
54 /^+[^}].*[^:*];/ {gsub(";","");sym=$2;
57 print map " " sym " " sec " add"
59 print map " " sym " unknown add"
64 # This is the same rule as above, but the rule matches on a
65 # leading - rather than a +, denoting that the symbol is being
67 /^-[^}].*[^:*];/ {gsub(";","");sym=$2;
70 print map " " sym " " sec " del"
72 print map " " sym " unknown del"
77 sort -u "$mapdb" > "$mapdb.2"
78 mv -f "$mapdb.2" "$mapdb"
82 check_for_rule_violations()
91 while read mname symname secname ar
96 if [ "$secname" = "unknown" ]
98 # Just inform the user of this occurrence, but
99 # don't flag it as an error
100 echo -n "INFO: symbol $syname is added but "
101 echo -n "patch has insuficient context "
102 echo -n "to determine the section name "
103 echo -n "please ensure the version is "
108 oldsecname=$(sed -n \
109 "s#$mname $symname \(.*\) del#\1#p" "$mapdb")
111 # A symbol can not enter a non experimental
113 if [ $? -ne 0 ] && [ "$secname" != 'EXPERIMENTAL' ]
115 echo -n "ERROR: symbol $symname "
116 echo -n "is added in the $secname "
117 echo -n "section, but is expected to "
118 echo -n "be added in the EXPERIMENTAL "
119 echo "section of the version map"
124 # This symbol is moving between two sections (the
125 # original section is not experimental).
126 # This can be legit, just warn.
127 if [ "$oldsecname" != 'EXPERIMENTAL' ]
129 echo -n "INFO: symbol $symname is being "
130 echo -n "moved from $oldsecname to $secname. "
131 echo -n "Ensure that it has gone through the "
132 echo "deprecation process"
137 if ! grep -q "$mname $symname .* add" "$mapdb" && \
138 [ "$secname" != "EXPERIMENTAL" ]
140 # Just inform users that non-experimenal
141 # symbols need to go through a deprecation
143 echo -n "INFO: symbol $symname is being "
144 echo -n "removed, ensure that it has "
145 echo "gone through the deprecation process"
153 trap clean_and_exit_on_sig EXIT
155 mapfile=`mktemp -t dpdk.mapdb.XXXXXX`
159 clean_and_exit_on_sig()
165 build_map_changes "$patch" "$mapfile"
166 check_for_rule_violations "$mapfile"