plugin_layout_with_alignment.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. # plugin_layout_with_alignment.sh -- test
  3. # Copyright (C) 2016-2022 Free Software Foundation, Inc.
  4. # Written by Than McIntosh <thanm@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. # The goal of this program is to verify plugin alignment and size
  19. # interfaces and working correctly in combination with section ordering.
  20. # intended. File plugin_layout_with_alignment.cc is in this test.
  21. set -e
  22. check()
  23. {
  24. awk "
  25. BEGIN { saw1 = 0; saw2 = 0; saw3 = 0; saw4 = 0; counter = 1; err = 0; ord = \"\"; }
  26. /.*$2\$/ { saw1 = counter; counter = counter + 1; ord = ord \" $2\"; }
  27. /.*$3\$/ { saw2 = counter; counter = counter + 1; ord = ord \" $3\"; }
  28. /.*$4\$/ { saw3 = counter; counter = counter + 1; ord = ord \" $4\"; }
  29. /.*$5\$/ { saw4 = counter; counter = counter + 1; ord = ord \" $5\"; }
  30. END {
  31. if (!saw1) {
  32. printf \"did not see $2\\n\";
  33. exit 1;
  34. }
  35. if (!saw2) {
  36. printf \"did not see $3\\n\";
  37. exit 1;
  38. }
  39. if (!saw3) {
  40. printf \"did not see $4\\n\";
  41. exit 1;
  42. }
  43. if (!saw4) {
  44. printf \"did not see $5\\n\";
  45. exit 1;
  46. }
  47. if (saw1 != 1 || saw2 != 2 || saw3 != 3 || saw4 != 4) {
  48. printf \"incorrect ordering:\\nwas:%s\\nshould have been: $2 $3 $4 $5\\n\", ord;
  49. exit 1;
  50. }
  51. }" $1
  52. }
  53. check plugin_layout_with_alignment.stdout "bss_item3" "bss_item1" "bss_item4" "bss_item2"
  54. check plugin_layout_with_alignment.stdout "rwdata_item2" "rwdata_item4" "rwdata_item1" "rwdata_item3"
  55. check plugin_layout_with_alignment.stdout "rodata_item3" "rodata_item1" "rodata_item2" "rodata_item4"