discard_locals_test.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. # discard_locals_test.sh -- test that local symbols are discarded.
  3. # Copyright (C) 2009-2015 Free Software Foundation, Inc.
  4. # Written by Doug Kwan <dougkwan@google.com>
  5. # This file is part of gold.
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. # This program 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. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. # MA 02110-1301, USA.
  18. # This file goes with exclude_libs_test.c, a C source file
  19. # linked with option -Wl,--exclude-libs. We run readelf on
  20. # the resulting executable and check that symbols from two test library
  21. # archives are correctly hidden or left unmodified.
  22. check_discarded()
  23. {
  24. file=$1
  25. sym=$2
  26. found=`egrep $sym $file`
  27. if test -n "$found"; then
  28. echo "These local symbols are not discarded in $file:"
  29. echo "$found"
  30. exit 1
  31. fi
  32. }
  33. check_non_discarded()
  34. {
  35. file=$1
  36. sym=$2
  37. found=`egrep $sym $file`
  38. if test -z "$found"; then
  39. echo "This local symbol is discarded in $file:"
  40. echo "$2"
  41. exit 1
  42. fi
  43. }
  44. check_discarded "discard_locals_test.syms" "should_be_discarded"
  45. check_non_discarded "discard_locals_relocatable_test1.syms" ".LC0"
  46. check_discarded "discard_locals_relocatable_test1.syms" "should_be_discarded"
  47. check_non_discarded "discard_locals_relocatable_test2.syms" ".LC0"
  48. check_discarded "discard_locals_relocatable_test2.syms" "should_be_discarded"
  49. exit 0