From patchwork Fri Nov 8 16:25:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 62791 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65EACA04B4; Fri, 8 Nov 2019 17:27:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 25DAC1C1D9; Fri, 8 Nov 2019 17:26:31 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 33D2A1C0C8 for ; Fri, 8 Nov 2019 17:26:29 +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 fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Nov 2019 08:26:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,282,1569308400"; d="scan'208";a="196947679" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.151]) by orsmga008.jf.intel.com with ESMTP; 08 Nov 2019 08:26:26 -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: Fri, 8 Nov 2019 16:25:31 +0000 Message-Id: <44a34951076b32f75022ebf856a2b10c2cdbc504.1573230233.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 v7 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