list-symbols.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. #
  3. # Copyright The Mbed TLS Contributors
  4. # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  5. #
  6. # This file is provided under the Apache License 2.0, or the
  7. # GNU General Public License v2.0 or later.
  8. #
  9. # **********
  10. # Apache License 2.0:
  11. #
  12. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  13. # not use this file except in compliance with the License.
  14. # You may obtain a copy of the License at
  15. #
  16. # http://www.apache.org/licenses/LICENSE-2.0
  17. #
  18. # Unless required by applicable law or agreed to in writing, software
  19. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  20. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. # See the License for the specific language governing permissions and
  22. # limitations under the License.
  23. #
  24. # **********
  25. #
  26. # **********
  27. # GNU General Public License v2.0 or later:
  28. #
  29. # This program is free software; you can redistribute it and/or modify
  30. # it under the terms of the GNU General Public License as published by
  31. # the Free Software Foundation; either version 2 of the License, or
  32. # (at your option) any later version.
  33. #
  34. # This program is distributed in the hope that it will be useful,
  35. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. # GNU General Public License for more details.
  38. #
  39. # You should have received a copy of the GNU General Public License along
  40. # with this program; if not, write to the Free Software Foundation, Inc.,
  41. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  42. #
  43. # **********
  44. set -eu
  45. if [ -d include/mbedtls ]; then :; else
  46. echo "$0: must be run from root" >&2
  47. exit 1
  48. fi
  49. if grep -i cmake Makefile >/dev/null; then
  50. echo "$0: not compatible with cmake" >&2
  51. exit 1
  52. fi
  53. cp include/mbedtls/config.h include/mbedtls/config.h.bak
  54. scripts/config.pl full
  55. make clean
  56. make_ret=
  57. CFLAGS=-fno-asynchronous-unwind-tables make lib \
  58. >list-symbols.make.log 2>&1 ||
  59. {
  60. make_ret=$?
  61. echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make lib"
  62. cat list-symbols.make.log >&2
  63. }
  64. rm list-symbols.make.log
  65. mv include/mbedtls/config.h.bak include/mbedtls/config.h
  66. if [ -n "$make_ret" ]; then
  67. exit "$make_ret"
  68. fi
  69. if uname | grep -F Darwin >/dev/null; then
  70. nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p'
  71. elif uname | grep -F Linux >/dev/null; then
  72. nm -og library/libmbed*.a | grep -v '^[^ ]*: *U \|^$\|^[^ ]*:$' | sed 's/^[^ ]* . //'
  73. fi | sort > exported-symbols
  74. make clean
  75. wc -l exported-symbols