1*d289c2baSAndroid Build Coastguard Worker#!/bin/bash 2*d289c2baSAndroid Build Coastguard Worker 3*d289c2baSAndroid Build Coastguard Worker# 4*d289c2baSAndroid Build Coastguard Worker# Copyright (C) 2016 The Android Open Source Project 5*d289c2baSAndroid Build Coastguard Worker# 6*d289c2baSAndroid Build Coastguard Worker# Permission is hereby granted, free of charge, to any person 7*d289c2baSAndroid Build Coastguard Worker# obtaining a copy of this software and associated documentation 8*d289c2baSAndroid Build Coastguard Worker# files (the "Software"), to deal in the Software without 9*d289c2baSAndroid Build Coastguard Worker# restriction, including without limitation the rights to use, copy, 10*d289c2baSAndroid Build Coastguard Worker# modify, merge, publish, distribute, sublicense, and/or sell copies 11*d289c2baSAndroid Build Coastguard Worker# of the Software, and to permit persons to whom the Software is 12*d289c2baSAndroid Build Coastguard Worker# furnished to do so, subject to the following conditions: 13*d289c2baSAndroid Build Coastguard Worker# 14*d289c2baSAndroid Build Coastguard Worker# The above copyright notice and this permission notice shall be 15*d289c2baSAndroid Build Coastguard Worker# included in all copies or substantial portions of the Software. 16*d289c2baSAndroid Build Coastguard Worker# 17*d289c2baSAndroid Build Coastguard Worker# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18*d289c2baSAndroid Build Coastguard Worker# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19*d289c2baSAndroid Build Coastguard Worker# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20*d289c2baSAndroid Build Coastguard Worker# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21*d289c2baSAndroid Build Coastguard Worker# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22*d289c2baSAndroid Build Coastguard Worker# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23*d289c2baSAndroid Build Coastguard Worker# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24*d289c2baSAndroid Build Coastguard Worker# SOFTWARE. 25*d289c2baSAndroid Build Coastguard Worker# 26*d289c2baSAndroid Build Coastguard Worker 27*d289c2baSAndroid Build Coastguard Worker# This shell-script checks the symbols in libavb.a and fails 28*d289c2baSAndroid Build Coastguard Worker# if a reference not starting with avb_ is referenced. It's intended 29*d289c2baSAndroid Build Coastguard Worker# to catch mistakes where the standard C library is inadvertently 30*d289c2baSAndroid Build Coastguard Worker# used. 31*d289c2baSAndroid Build Coastguard Worker 32*d289c2baSAndroid Build Coastguard Workerset -e 33*d289c2baSAndroid Build Coastguard Worker 34*d289c2baSAndroid Build Coastguard WorkerSYMBOLS_FILE=$(mktemp /tmp/libavb_symbols.XXXXXXXXXX) 35*d289c2baSAndroid Build Coastguard Worker 36*d289c2baSAndroid Build Coastguard Workertrap "rm -f '${SYMBOLS_FILE}'" EXIT 37*d289c2baSAndroid Build Coastguard Worker 38*d289c2baSAndroid Build Coastguard Workerreadelf --symbols --wide "${ANDROID_HOST_OUT}/obj/STATIC_LIBRARIES/libavb_intermediates/libavb.a" | \ 39*d289c2baSAndroid Build Coastguard Worker awk '$7 == "UND" && $8 != "" {print $8}' | \ 40*d289c2baSAndroid Build Coastguard Worker grep -v ^avb_ | \ 41*d289c2baSAndroid Build Coastguard Worker sort -u > "${SYMBOLS_FILE}" 42*d289c2baSAndroid Build Coastguard Worker 43*d289c2baSAndroid Build Coastguard Worker# If this file is non-empty, it means that the library is using 44*d289c2baSAndroid Build Coastguard Worker# symbols not starting with "avb_". 45*d289c2baSAndroid Build Coastguard Workerif [ -s "${SYMBOLS_FILE}" ] ; then 46*d289c2baSAndroid Build Coastguard Worker echo "ERROR: $0: Unexpected symbols in libavb:" >&2 47*d289c2baSAndroid Build Coastguard Worker cat "${SYMBOLS_FILE}" >&2 48*d289c2baSAndroid Build Coastguard Worker exit 1 49*d289c2baSAndroid Build Coastguard Workerfi 50