aarch64_reloc_none.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. # aarch64_reloc_none.sh -- test that R_AARCH64_NONE can be used
  3. # to prevent garbage collecting a section.
  4. # Copyright (C) 2010-2022 Free Software Foundation, Inc.
  5. # Written by Igor Kudrin <ikudrin@accesssoftek.com>.
  6. # This file is part of gold.
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # (at your option) any later version.
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  18. # MA 02110-1301, USA.
  19. # The goal of this test is to verify that support for the R_AARCH64_NONE
  20. # relocation is implemented and it can be used to inform a linker that
  21. # a section should be preserved during garbage collecting.
  22. # File aarch64_reloc_none.s describes two similar sections, .foo and .bar,
  23. # but .foo is referenced from .text using R_AARCH64_NONE against symbol foo.
  24. # When flag --gc-sections is used, .foo and its symbol foo have to be
  25. # preserved, whereas .bar and its symbol bar have to be discarded.
  26. check()
  27. {
  28. file=$1
  29. found_bar=`grep -e "\<bar\b" "$file"`
  30. if test -n "$found_bar"; then
  31. echo "Garbage collection failed to collect bar"
  32. echo ""
  33. echo "Actual output below:"
  34. cat "$file"
  35. exit 1
  36. fi
  37. found_foo=`grep -e "\<foo\b" "$file"`
  38. if test -z "$found_foo"; then
  39. echo "Garbage collection should not discard foo"
  40. echo ""
  41. echo "Actual output below:"
  42. cat "$file"
  43. exit 1
  44. fi
  45. }
  46. check aarch64_reloc_none.stdout