strip_nonapi 969 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh -e
  2. # This script is designed to remove all non-API global symbols from an object
  3. # file. The only global symbols that should be retained are those that belong
  4. # to the official namespace. Unfortunately doing this is platform-specific, as
  5. # the object file manipulation tools are not consistent across platforms.
  6. #
  7. # On platforms where this script does not know what to do, the object file
  8. # will retain non-API global symbols, and this may have unpleasant side effects.
  9. #
  10. # Prefixes that belong to the official namespace are:
  11. # ast_
  12. # _ast_
  13. # __ast_
  14. # astman_
  15. # pbx_
  16. # resample_
  17. FILTER="${GREP} -v -e ^ast_ -e ^_ast_ -e ^__ast_ -e ^astman_ -e ^pbx_ -e ^resample_"
  18. case "${PROC}" in
  19. powerpc64)
  20. TEXTSYM=" D "
  21. ;;
  22. *)
  23. TEXTSYM=" T "
  24. ;;
  25. esac
  26. case "${OSARCH}" in
  27. linux-gnu|FreeBSD)
  28. nm ${1} | ${GREP} -e "$TEXTSYM" | cut -d" " -f3 | ${FILTER} > striplist
  29. sed -e "s/^/-N /" striplist | xargs -n 40 ${STRIP} ${1}
  30. rm -f striplist
  31. ;;
  32. *)
  33. ;;
  34. esac