blob: 8bdc55f81af2e67e1ab5df7a3fc6a2973d308580 [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#
Bence Szépkúti1e148272020-08-07 13:07:28 +02003# Copyright The Mbed TLS Contributors
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.
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010017
18set -eu
19
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020020if [ -d include/mbedtls ]; then :; else
21 echo "$0: must be run from root" >&2
22 exit 1
23fi
24
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010025if grep -i cmake Makefile >/dev/null; then
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020026 echo "$0: not compatible with cmake" >&2
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010027 exit 1
28fi
29
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +020030cp include/mbedtls/config.h include/mbedtls/config.h.bak
Gilles Peskine5d46f6a2019-07-27 23:52:53 +020031scripts/config.py full
Jaeden Amero3b025ac2019-05-31 12:26:42 +010032make clean
Gilles Peskine9a52cf32019-05-22 18:22:58 +020033make_ret=
Jaeden Amero3b025ac2019-05-31 12:26:42 +010034CFLAGS=-fno-asynchronous-unwind-tables make lib \
Gilles Peskine9a52cf32019-05-22 18:22:58 +020035 >list-symbols.make.log 2>&1 ||
36 {
37 make_ret=$?
Jaeden Amero3b025ac2019-05-31 12:26:42 +010038 echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make lib"
Gilles Peskine9a52cf32019-05-22 18:22:58 +020039 cat list-symbols.make.log >&2
40 }
41rm list-symbols.make.log
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +020042mv include/mbedtls/config.h.bak include/mbedtls/config.h
Gilles Peskine9a52cf32019-05-22 18:22:58 +020043if [ -n "$make_ret" ]; then
44 exit "$make_ret"
45fi
46
Manuel Pégourié-Gonnardbf6ed082015-08-04 17:34:18 +020047if uname | grep -F Darwin >/dev/null; then
Christoph M. Wintersteiger9b33e7d2018-12-14 13:34:06 +000048 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 +020049elif uname | grep -F Linux >/dev/null; then
Christoph M. Wintersteiger9b33e7d2018-12-14 13:34:06 +000050 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 +020051fi | sort > exported-symbols
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010052make clean
53
54wc -l exported-symbols