From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF55CA04C1; Wed, 20 Nov 2019 18:25:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EFE7C2BA3; Wed, 20 Nov 2019 18:25:04 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id C1C932B8B for ; Wed, 20 Nov 2019 18:25:03 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2019 09:25:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,222,1571727600"; d="scan'208";a="200794386" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.151]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2019 09:25:00 -0800 From: Anatoly Burakov To: dev@dpdk.org Cc: Marcin Baran , john.mcnamara@intel.com, ray.kinsella@intel.com, bruce.richardson@intel.com, thomas@monjalon.net, david.marchand@redhat.com, Pawel Modrak Date: Wed, 20 Nov 2019 17:23:39 +0000 Message-Id: <9119a0d0d1cf891b9c2dfafe2146d40e9d83daf1.1574270323.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v8 12/12] buildtools: add ABI versioning check script X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Marcin Baran Add a shell script that checks whether built libraries are versioned with expected ABI (current ABI, current ABI + 1, or EXPERIMENTAL). The following command was used to verify current source tree (assuming build directory is in ./build): find ./build/lib ./build/drivers -name \*.so \ -exec ./buildtools/check-abi-version.sh {} \; -print Signed-off-by: Marcin Baran Signed-off-by: Pawel Modrak Signed-off-by: Anatoly Burakov Acked-by: Bruce Richardson --- Notes: v2: - Moved this to the end of the patchset - Fixed bug when ABI symbols were not found because the .so did not declare any public symbols buildtools/check-abi-version.sh | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 buildtools/check-abi-version.sh diff --git a/buildtools/check-abi-version.sh b/buildtools/check-abi-version.sh new file mode 100755 index 0000000000..9a3d135463 --- /dev/null +++ b/buildtools/check-abi-version.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2019 Intel Corporation + +# Check whether library symbols have correct +# version (provided ABI number or provided ABI +# number + 1 or EXPERIMENTAL). +# Args: +# $1: path of the library .so file +# $2: ABI major version number to check +# (defaults to ABI_VERSION file value) + +if [ -z "$1" ]; then + echo "Script checks whether library symbols have" + echo "correct version (ABI_VER/ABI_VER+1/EXPERIMENTAL)" + echo "Usage:" + echo " $0 SO_FILE_PATH [ABI_VER]" + exit 1 +fi + +LIB="$1" +DEFAULT_ABI=$(cat "$(dirname \ + $(readlink -f $0))/../ABI_VERSION" | \ + cut -d'.' -f 1) +ABIVER="DPDK_${2-$DEFAULT_ABI}" +NEXT_ABIVER="DPDK_$((${2-$DEFAULT_ABI}+1))" + +ret=0 + +# get output of objdump +OBJ_DUMP_OUTPUT=`objdump -TC --section=.text ${LIB} 2>&1 | grep ".text"` + +# there may not be any .text sections in the .so file, in which case exit early +echo "${OBJ_DUMP_OUTPUT}" | grep "not found in any input file" -q +if [ "$?" -eq 0 ]; then + exit 0 +fi + +# we have symbols, so let's see if the versions are correct +for SYM in $(echo "${OBJ_DUMP_OUTPUT}" | awk '{print $(NF-1) "-" $NF}') +do + version=$(echo $SYM | cut -d'-' -f 1) + symbol=$(echo $SYM | cut -d'-' -f 2) + case $version in (*"$ABIVER"*|*"$NEXT_ABIVER"*|"EXPERIMENTAL") + ;; + (*) + echo "Warning: symbol $symbol ($version) should be annotated " \ + "as ABI version $ABIVER / $NEXT_ABIVER, or EXPERIMENTAL." + ret=1 + ;; + esac +done + +exit $ret -- 2.17.1