2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright(c) 2019 Intel Corporation
5 # Check whether library symbols have correct
6 # version (provided ABI number or provided ABI
7 # number + 1 or EXPERIMENTAL or INTERNAL).
9 # $1: path of the library .so file
10 # $2: ABI major version number to check
11 # (defaults to ABI_VERSION file value)
14 echo "Script checks whether library symbols have"
15 echo "correct version (ABI_VER/ABI_VER+1/EXPERIMENTAL/INTERNAL)"
17 echo " $0 SO_FILE_PATH [ABI_VER]"
22 DEFAULT_ABI=$(cat "$(dirname \
23 $(readlink -f $0))/../ABI_VERSION" | \
25 ABIVER="DPDK_${2-$DEFAULT_ABI}"
26 NEXT_ABIVER="DPDK_$((${2-$DEFAULT_ABI}+1))"
30 # get output of objdump
31 OBJ_DUMP_OUTPUT=`objdump -TC --section=.text ${LIB} 2>&1 | grep ".text"`
33 # there may not be any .text sections in the .so file, in which case exit early
34 echo "${OBJ_DUMP_OUTPUT}" | grep "not found in any input file" -q
35 if [ "$?" -eq 0 ]; then
39 # we have symbols, so let's see if the versions are correct
40 for SYM in $(echo "${OBJ_DUMP_OUTPUT}" | awk '{print $(NF-1) "-" $NF}')
42 version=$(echo $SYM | cut -d'-' -f 1)
43 symbol=$(echo $SYM | cut -d'-' -f 2)
44 case $version in (*"$ABIVER"*|*"$NEXT_ABIVER"*|"EXPERIMENTAL"|"INTERNAL")
47 echo "Warning: symbol $symbol ($version) should be annotated " \
48 "as ABI version $ABIVER / $NEXT_ABIVER, EXPERIMENTAL, or INTERNAL."