pr21430.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. # pr21430.sh -- test the position of a relaxed section.
  3. # Copyright (C) 2017-2022 Free Software Foundation, Inc.
  4. # Written by Igor Kudrin <ikudrin@accesssoftek.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. file=pr21430.stdout
  19. get_symbol_address()
  20. {
  21. symbol=$1
  22. var=$2
  23. pattern="\<$symbol\>"
  24. found=`grep "$pattern" "$file"`
  25. if test -z "$found"; then
  26. echo "Symbol '$symbol' not found in file $file."
  27. echo "Search pattern: $pattern"
  28. echo ""
  29. echo "Actual output below:"
  30. cat "$file"
  31. exit 1
  32. fi
  33. eval $var="0x0`echo $found | awk '{ print $1 }'`"
  34. }
  35. get_symbol_size()
  36. {
  37. symbol=$1
  38. var=$2
  39. pattern="\<$symbol\>"
  40. found=`grep "$pattern" "$file"`
  41. if test -z "$found"; then
  42. echo "Symbol '$symbol' not found in file $file."
  43. echo "Search pattern: $pattern"
  44. echo ""
  45. echo "Actual output below:"
  46. cat "$file"
  47. exit 1
  48. fi
  49. eval $var="0x0`echo $found | awk '{ print $2 }'`"
  50. }
  51. get_symbol_address "bar" bar_address
  52. get_symbol_size "bar" bar_size
  53. get_symbol_address "foo" foo_address
  54. if test $(($foo_address)) -lt $(($bar_address+$bar_size)); then
  55. echo "'foo' should not overlap the content of 'bar'."
  56. echo ""
  57. echo "Actual output below:"
  58. cat "$file"
  59. exit 1
  60. fi
  61. exit 0