[dpdk-dev] [PATCH 5/9] buildtools: detect discrepancies for experimental symbols

David Marchand david.marchand at redhat.com
Thu Jun 27 13:33:51 CEST 2019


When promoting those symbols as stable, there is no check to ensure that
the final result is consistent.

Add a little script to get the symbols per section from the library map
files.
Validate that all experimental symbols in object files are referenced by
library map files.

Signed-off-by: David Marchand <david.marchand at redhat.com>
---
 buildtools/check-experimental-syms.sh | 29 +++++++++++----
 buildtools/map-list-symbol.sh         | 70 +++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+), 7 deletions(-)
 create mode 100755 buildtools/map-list-symbol.sh

diff --git a/buildtools/check-experimental-syms.sh b/buildtools/check-experimental-syms.sh
index 7d1f3a5..653756e 100755
--- a/buildtools/check-experimental-syms.sh
+++ b/buildtools/check-experimental-syms.sh
@@ -5,6 +5,8 @@
 MAPFILE=$1
 OBJFILE=$2
 
+LIST_SYMBOL=$RTE_SDK/buildtools/map-list-symbol.sh
+
 # added check for "make -C test/" usage
 if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
 then
@@ -16,12 +18,9 @@ then
 	exit 0
 fi
 
-for i in `awk 'BEGIN {found=0}
-		/.*EXPERIMENTAL.*/ {found=1}
-		/.*}.*;/ {found=0}
-		/.*;/ {if (found == 1) print $1}' $MAPFILE`
+ret=0
+for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE`
 do
-	SYM=`echo $i | sed -e"s/;//"`
 	objdump -t $OBJFILE | grep -q "\.text.*$SYM$"
 	IN_TEXT=$?
 	objdump -t $OBJFILE | grep -q "\.text\.experimental.*$SYM$"
@@ -33,8 +32,24 @@ do
 		but is listed in version map
 		Please add __rte_experimental to the definition of $SYM
 		END_OF_MESSAGE
-		exit 1
+		ret=1
 	fi
 done
-exit 0
 
+for SYM in `objdump -t $OBJFILE |awk '{
+	if ($2 != "l" && $4 == ".text.experimental") {
+		print $NF
+	}
+}'`
+do
+	$LIST_SYMBOL -S EXPERIMENTAL -s $SYM -q $MAPFILE || {
+		cat >&2 <<- END_OF_MESSAGE
+		$SYM is flagged as experimental
+		but is not listed in version map
+		Please add $SYM to the version map
+		END_OF_MESSAGE
+		ret=1
+	}
+done
+
+exit $ret
diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh
new file mode 100755
index 0000000..5509b4a
--- /dev/null
+++ b/buildtools/map-list-symbol.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 David Marchand <david.marchand at redhat.com>
+
+section=all
+symbol=all
+quiet=
+
+while getopts 'S:s:q' name; do
+	case $name in
+	S)
+		[ $section = 'all' ] || {
+			echo 'Cannot list in multiple sections'
+			exit 1
+		}
+		section=$OPTARG
+	;;
+	s)
+		[ $symbol = 'all' ] || {
+			echo 'Cannot list multiple symbols'
+			exit 1
+		}
+		symbol=$OPTARG
+	;;
+	q)
+		quiet='y'
+	;;
+	?)
+		echo 'usage: $0 [-S section] [-s symbol] [-q]'
+		exit 1
+	;;
+	esac
+done
+
+shift $(($OPTIND - 1))
+
+for file in $@; do
+	cat "$file" |awk '
+	BEGIN {
+		current_section = "";
+		if ("'$section'" == "all" && "'$symbol'" == "all") {
+			ret = 0;
+		} else {
+			ret = 1;
+		}
+	}
+	/^.*{/ {
+		if ("'$section'" == "all" || $1 == "'$section'") {
+			current_section = $1;
+		}
+	}
+	/.*}/ { current_section = ""; }
+	/^[^}].*[^:*];/ {
+		if (current_section != "") {
+			gsub(";","");
+			if ("'$symbol'" == "all" || $1 == "'$symbol'") {
+				ret = 0;
+				if ("'$quiet'" == "") {
+					print "'$file' "current_section" "$1;
+				}
+				if ("'$symbol'" != "all") {
+					exit 0;
+				}
+			}
+		}
+	}
+	END {
+		exit ret;
+	}'
+done
-- 
1.8.3.1



More information about the dev mailing list