arm_target2_got_rel.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. # arm_target2_got_rel.sh -- test --target2=got-rel options.
  3. # This test is based on ld/testsuite/ld-arm/arm-target2-got-rel.d.
  4. # Copyright (C) 2016-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. check()
  20. {
  21. file=$1
  22. section=$2
  23. pattern=$3
  24. found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
  25. if test -z "$found"; then
  26. echo "Section \"$section\" not found in file $file"
  27. echo ""
  28. echo "Actual output below:"
  29. cat "$file"
  30. exit 1
  31. fi
  32. match_pattern=`echo "$found" | grep -e "$pattern"`
  33. if test -z "$match_pattern"; then
  34. echo "Expected pattern was not found in section \"$section\":"
  35. echo " $pattern"
  36. echo ""
  37. echo "Actual output below:"
  38. cat "$file"
  39. exit 1
  40. fi
  41. }
  42. # .got=0x9000
  43. # .got - 0x8000 = 0x1000
  44. # .got - 0x8004 + 0x1234 = 0x2230
  45. # .got - 0x8008 + 0xcdef0000 = 0xcdef0ff8
  46. # .got - 0x800c + 0x76543210 = 0x76544204
  47. check "arm_target2_got_rel.stdout" ".text" "\<8000[[:space:]]\+\(00100000\|00001000\)[[:space:]]\+\(30220000\|00002230\)[[:space:]]\+\(f80fefcd\|cdef0ff8\)[[:space:]]\+\(04425476\|76544204\)\b"
  48. # foo = 0x8010
  49. check "arm_target2_got_rel.stdout" ".got" "\<9000[[:space:]]\+\(10800000\|00008010\)\b"
  50. exit 0