map-address.exp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # Test address printed by --print-map
  2. # Copyright (C) 2002-2022 Free Software Foundation, Inc.
  3. #
  4. # This file is part of the GNU Binutils.
  5. #
  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. #
  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. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  19. # MA 02110-1301, USA.
  20. set testname "map addresses"
  21. # The source file doesn't matter. Pinch one from the sizeof test.
  22. if {![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/map-address.o]} {
  23. unsupported $testname
  24. return
  25. }
  26. if { [is_pecoff_format] } then {
  27. set IMAGE_BASE "--image-base 0"
  28. } else {
  29. set IMAGE_BASE ""
  30. }
  31. if {![ld_link $ld tmpdir/map-address \
  32. "$LDFLAGS -T $srcdir/$subdir/map-address.t \
  33. $IMAGE_BASE tmpdir/map-address.o \
  34. -Map tmpdir/map-address.map"]} {
  35. fail $testname
  36. return
  37. }
  38. if [is_remote host] then {
  39. remote_upload host "tmpdir/map_address.map"
  40. }
  41. if {[regexp_diff \
  42. "tmpdir/map-address.map" \
  43. "$srcdir/$subdir/map-address.d"]} {
  44. fail $testname
  45. } else {
  46. pass $testname
  47. }
  48. set testname "map to directory"
  49. if {![ld_link $ld tmpdir/map-address \
  50. "$LDFLAGS -T $srcdir/$subdir/map-address.t \
  51. $IMAGE_BASE tmpdir/map-address.o \
  52. -Map tmpdir --output fred"]} {
  53. fail $testname
  54. return
  55. }
  56. if [is_remote host] then {
  57. remote_upload host "tmpdir/fred.map"
  58. }
  59. if {[regexp_diff \
  60. "tmpdir/fred.map" \
  61. "$srcdir/$subdir/map-address.d"]} {
  62. fail $testname
  63. } else {
  64. pass $testname
  65. }
  66. set testname "map to % directory"
  67. if {![ld_link $ld tmpdir/map-address \
  68. "$LDFLAGS -T $srcdir/$subdir/map-address.t \
  69. $IMAGE_BASE tmpdir/map-address.o \
  70. -Map=tmpdir/% --output fred"]} {
  71. fail $testname
  72. return
  73. }
  74. if [is_remote host] then {
  75. remote_upload host "tmpdir/fred.map"
  76. }
  77. if {[regexp_diff \
  78. "tmpdir/fred.map" \
  79. "$srcdir/$subdir/map-address.d"]} {
  80. fail $testname
  81. } else {
  82. pass $testname
  83. }
  84. set testname "map to %.foo directory"
  85. if {![ld_link $ld tmpdir/map-address \
  86. "$LDFLAGS -T $srcdir/$subdir/map-address.t \
  87. $IMAGE_BASE tmpdir/map-address.o \
  88. -Map=tmpdir/%.foo --output fred"]} {
  89. fail $testname
  90. return
  91. }
  92. if [is_remote host] then {
  93. remote_upload host "tmpdir/fred.foo"
  94. }
  95. if {[regexp_diff \
  96. "tmpdir/fred.foo" \
  97. "$srcdir/$subdir/map-address.d"]} {
  98. fail $testname
  99. } else {
  100. pass $testname
  101. }