/gcc/libstdc++-v3/scripts/extract_symvers.in

https://github.com/AsherBond/MondocosmOS-Dependencies · Autoconf · 70 lines · 35 code · 9 blank · 26 comment · 11 complexity · c9b595e57de285bb05aec6dbf1e7acfe MD5 · raw file

  1. #!/bin/sh
  2. # Copyright (C) 2002, 2003, 2009, 2010 Free Software Foundation, Inc.
  3. #
  4. # This file is part of the GNU ISO C++ Library. This library is free
  5. # software; you can redistribute it and/or modify it under the
  6. # terms of the GNU General Public License as published by the
  7. # Free Software Foundation; either version 3, or (at your option)
  8. # any later version.
  9. #
  10. # This library is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License along
  16. # with this library; see the file COPYING3. If not see
  17. # <http://www.gnu.org/licenses/>.
  18. if test ${#} -lt 2 || test $1 = '--help'; then
  19. echo "Usage: extract_symvers shared_lib output_file" 1>&2
  20. exit 1
  21. fi
  22. lib=$1
  23. output=$2
  24. # This avoids weird sorting problems later.
  25. LC_ALL=C
  26. export LC_ALL
  27. LANG=C
  28. export LANG
  29. tmp=extract.$$
  30. case `uname -s` in
  31. SunOS)
  32. # Ensure that output on Solaris 2 matches readelf below without requiring
  33. # GNU binutils to be installed. This requires a combination of pvs and
  34. # elfdump, which is easier handled in a perl script.
  35. perl @glibcxx_srcdir@/scripts/extract_symvers.pl ${lib} > $tmp 2>&1
  36. ;;
  37. *)
  38. # GNU binutils, somewhere after version 2.11.2, requires -W/--wide to
  39. # avoid default line truncation. -W is not supported and truncation did
  40. # not occur by default before that point.
  41. readelf="readelf --symbols"
  42. if readelf --help | grep -- --wide > /dev/null; then
  43. readelf="$readelf --wide"
  44. fi
  45. ${readelf} ${lib} |\
  46. sed -e 's/ \[<other>: [A-Fa-f0-9]*\] //' -e '/\.dynsym/,/^$/p;d' |\
  47. egrep -v ' (LOCAL|UND) ' |\
  48. sed -e 's/ <processor specific>: / <processor_specific>:_/g' |\
  49. sed -e 's/ <OS specific>: / <OS_specific>:_/g' |\
  50. sed -e 's/ <unknown>: / <unknown>:_/g' |\
  51. awk '{ if ($4 == "FUNC" || $4 == "NOTYPE")
  52. printf "%s:%s\n", $4, $8;
  53. else if ($4 == "OBJECT" || $4 == "TLS")
  54. printf "%s:%s:%s\n", $4, $3, $8;
  55. }' | sort | uniq > $tmp 2>&1
  56. # else printf "Huh? What is %s?\n", $8;
  57. ;;
  58. esac
  59. # I think we'll be doing some more with this file, but for now, dump.
  60. mv $tmp $output
  61. exit 0