• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Usage: check-syms.sh TA.elf libc.so libtee.so
3# Copyright (C) 2022 Huawei Technologies Co., Ltd.
4# Licensed under the Mulan PSL v2.
5# You can use this software according to the terms and conditions of the Mulan PSL v2.
6# You may obtain a copy of Mulan PSL v2 at:
7#     http://license.coscl.org.cn/MulanPSL2
8# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
9# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
10# PURPOSE.
11# See the Mulan PSL v2 for more details.
12
13# add ignored syms to IGNORED
14IGNORED=$(echo cfi_disabled; echo llvm_gcov_init; echo llvm_gcov_reset; echo llvm_gcov_dump;)
15# add undefined syms to UNDEF
16UNDEF=$(objdump -T "$1" | grep '\*UND\*' | egrep -o '[^ ]+$')
17
18# add defined syms to ALLDEF
19# ALLDEF for check:
20# libc_shared_a32.so             libc_shared_a32.so
21# libtee_shared_a32.so           libtee_shared.so
22# libdrv_shared_a32.so           libdrv_shared.so
23ALLDEF="$IGNORED\n"
24DEF_NUM=1
25for i in $* ; do
26if [ $DEF_NUM -gt 1 ] ; then
27DEF[$DEF_NUM]=$(objdump -T "$i" | grep -v '\*UND\*' | egrep -o '[^ ]+$')
28ALLDEF=${ALLDEF}"${DEF[$DEF_NUM]}\n"
29fi
30let DEF_NUM++
31done
32
33# check undefined syms
34for sym in $UNDEF ; do
35if ! (echo -e "$ALLDEF" | grep -qs "^$sym$") ; then
36echo "$(basename $1) contains undefined symbol $sym"
37exit 1
38fi
39done
40exit 0
41