blob: f4c20b24c0fb5edbb80d4a50628593458a0c640b [file] [log] [blame]
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +01001#!/bin/sh
Bence Szépkúti700ee442020-05-26 00:33:31 +02002#
3# Copyright (C) 2015-2019, Arm Limited, All Rights Reserved
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02004# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
Bence Szépkúti700ee442020-05-26 00:33:31 +020017#
18# This file is part of Mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010019
20set -eu
21
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020022if [ -d include/mbedtls ]; then :; else
23 echo "$0: must be run from root" >&2
24 exit 1
25fi
26
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010027if grep -i cmake Makefile >/dev/null; then
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020028 echo "$0: not compatible with cmake" >&2
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010029 exit 1
30fi
31
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +020032cp include/mbedtls/config.h include/mbedtls/config.h.bak
Gilles Peskine5d46f6a2019-07-27 23:52:53 +020033scripts/config.py full
Jaeden Amero3b025ac2019-05-31 12:26:42 +010034make clean
Gilles Peskine9a52cf32019-05-22 18:22:58 +020035make_ret=
Jaeden Amero3b025ac2019-05-31 12:26:42 +010036CFLAGS=-fno-asynchronous-unwind-tables make lib \
Gilles Peskine9a52cf32019-05-22 18:22:58 +020037 >list-symbols.make.log 2>&1 ||
38 {
39 make_ret=$?
Jaeden Amero3b025ac2019-05-31 12:26:42 +010040 echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make lib"
Gilles Peskine9a52cf32019-05-22 18:22:58 +020041 cat list-symbols.make.log >&2
42 }
43rm list-symbols.make.log
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +020044mv include/mbedtls/config.h.bak include/mbedtls/config.h
Gilles Peskine9a52cf32019-05-22 18:22:58 +020045if [ -n "$make_ret" ]; then
46 exit "$make_ret"
47fi
48
Manuel Pégourié-Gonnardbf6ed082015-08-04 17:34:18 +020049if uname | grep -F Darwin >/dev/null; then
Christoph M. Wintersteiger9b33e7d2018-12-14 13:34:06 +000050 nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p' | grep -v -e ^FStar -e ^Hacl
Manuel Pégourié-Gonnardbf6ed082015-08-04 17:34:18 +020051elif uname | grep -F Linux >/dev/null; then
Christoph M. Wintersteiger9b33e7d2018-12-14 13:34:06 +000052 nm -og library/libmbed*.a | grep -v '^[^ ]*: *U \|^$\|^[^ ]*:$' | sed 's/^[^ ]* . //' | grep -v -e ^FStar -e ^Hacl
Manuel Pégourié-Gonnardbf6ed082015-08-04 17:34:18 +020053fi | sort > exported-symbols
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010054make clean
55
56wc -l exported-symbols