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 6D893A317C for ; Thu, 17 Oct 2019 16:33:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D3F861E9D0; Thu, 17 Oct 2019 16:32:44 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 0CC621E9BD for ; Thu, 17 Oct 2019 16:32:42 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2019 07:32:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,308,1566889200"; d="scan'208";a="396282462" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.151]) by fmsmga005.fm.intel.com with ESMTP; 17 Oct 2019 07:32:40 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Marcin Baran , john.mcnamara@intel.com, bruce.richardson@intel.com, thomas@monjalon.net, david.marchand@redhat.com, Pawel Modrak Date: Thu, 17 Oct 2019 15:32:00 +0100 Message-Id: <8931c75880b0fb33f4215d90f8ac468ec623250e.1571322634.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 v4 10/10] 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..29aea97735 --- /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))/../config/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