aix52.exp 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. # Expect script for AIX 5.2+ tests
  2. # Copyright (C) 2009-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. #
  21. if { ![istarget "powerpc*-*-aix\[5-9\]*"] && ![istarget "rs6000-*-aix\[5-9\]*"]
  22. || [istarget "*-*-aix5.\[01\]*"] } {
  23. return
  24. }
  25. # Run a run_link_tests-style test for AIX. SIZE selects the target size
  26. # (32 or 64). The other arguments are elements of a run_link_tests test.
  27. #
  28. # Make the following changes before running the test:
  29. #
  30. # - Mention SIZE in the test name.
  31. # - Add "-aSIZE --defsym size=SIZE" to the assembler options.
  32. # - Add the source directory to any "-bI:" and "-bE:" linker options.
  33. # - Add "-bSIZE" to the linker options.
  34. # - Add "-XSIZE" to the archiver options.
  35. # - Replace "SIZE" with SIZE in TOOLS.
  36. # - When testing 64-bit targets:
  37. # - Turn tmpdir/aix-* into tmpdir/aix64-*.
  38. # - Turn tmpdir/libaix-* into tmpdir/libaix64-*.
  39. # - Turn -laix* into -laix64*, to compensate for the above.
  40. proc run_aix_test { size name ldopts asopts sources tools output } {
  41. global srcdir subdir
  42. if { $size == 64 } {
  43. regsub -all {tmpdir/aix-} $ldopts {tmpdir/aix64-} ldopts
  44. regsub {^aix} $output {aix64} output
  45. regsub -all -- {-laix-} $ldopts {-laix64-} ldopts
  46. regsub {^libaix} $output {libaix64} output
  47. }
  48. if { [regexp {.a$} $output] } {
  49. append ldopts " -X$size"
  50. } else {
  51. regsub -all {(-b[IE]):} $ldopts "\\1:$srcdir/$subdir/" ldopts
  52. append ldopts " -b$size"
  53. }
  54. regsub -all {SIZE} $tools $size tools
  55. run_ld_link_tests [list [list "$name ($size-bit)" \
  56. $ldopts "" \
  57. "$asopts -a$size --defsym size=$size" \
  58. $sources \
  59. $tools \
  60. $output]]
  61. }
  62. foreach file { "aix-lineno-1.txt" } {
  63. remote_upload host "$srcdir/$subdir/$file" "tmpdir/$file"
  64. }
  65. set aix52tests {
  66. {"Absolute branch test 1"
  67. "-shared -bI:aix-abs-branch-1.im -bE:aix-abs-branch-1.ex"
  68. "" {aix-abs-branch-1.s}
  69. {{objdump {-dR} aix-abs-branch-1.dd} {nm {} aix-abs-branch-1-SIZE.nd}}
  70. "aix-abs-branch-1.so"}
  71. {"Relocations against absolute symbols 1"
  72. "-shared -bI:aix-abs-reloc-1.im -bE:aix-abs-reloc-1.ex"
  73. {} {aix-abs-reloc-1.s}
  74. {{objdump -sRj.data aix-abs-reloc-1-SIZE.od}
  75. {nm {} aix-abs-reloc-1-SIZE.nd}}
  76. "aix-abs-reloc-1.so"}
  77. {"Core sections test 1" "-shared -bE:aix-core-sec-1.ex"
  78. "" {aix-core-sec-1.s}
  79. {{objdump -h aix-core-sec-1.hd}}
  80. "aix-core-sec-1.so"}
  81. {"Core sections test 2" "-shared -bE:aix-core-sec-2.ex"
  82. "" {aix-core-sec-2.s}
  83. {{objdump -h aix-core-sec-2.hd}}
  84. "aix-core-sec-2.so"}
  85. {"Core sections test 3" "-shared -bE:aix-core-sec-3.ex"
  86. "" {aix-core-sec-3.s}
  87. {{objdump -h aix-core-sec-3.hd}}
  88. "aix-core-sec-3.so"}
  89. {"Duplicate symbol check 1 (rel)" "-r"
  90. "" {aix-no-dup-syms-1a.s aix-no-dup-syms-1b.s}
  91. {{nm {} aix-no-dup-syms-1-rel.nd} {objdump -r aix-no-dup-syms-1-rel.rd}}
  92. "aix-no-dup-syms-1.o"}
  93. {"Duplicate symbol check 1 (shared)"
  94. "-shared --allow-multiple-definition -bI:aix-no-dup-syms-1.im -bE:aix-no-dup-syms-1.ex"
  95. "" {aix-no-dup-syms-1a.s aix-no-dup-syms-1b.s}
  96. {{nm {} aix-no-dup-syms-1-dso-SIZE.nd}
  97. {objdump -r aix-no-dup-syms-1-dso-SIZE.rd}
  98. {nm -D aix-no-dup-syms-1-dso-SIZE.dnd}
  99. {objdump -R aix-no-dup-syms-1-dso-SIZE.drd}}
  100. "aix-no-dup-syms-1.so"}
  101. {"Export test 1 (archive)" ""
  102. "" {aix-export-1a.s}
  103. {} "libaix-export-1.a"}
  104. {"Export test 1 (object)" "-r"
  105. "" {aix-export-1b.s}
  106. {} "aix-export-1.o"}
  107. {"Export test 1 (-bexpall)"
  108. "-shared -bexpall tmpdir/aix-export-1.o -Ltmpdir -laix-export-1"
  109. "" {}
  110. {{objdump -dj.data aix-export-1-all-SIZE.dd}}
  111. "aix-export-1-all.so"}
  112. {"Export test 1 (-bexpfull)"
  113. "-shared -bexpfull tmpdir/aix-export-1.o -Ltmpdir -laix-export-1"
  114. "" {}
  115. {{objdump -dj.data aix-export-1-full-SIZE.dd}}
  116. "aix-export-1-full.so"}
  117. {"Export test 2" "-shared -bexpall"
  118. {} {aix-export-2.s}
  119. {{nm -D aix-export-2-SIZE.nd}} "aix-export-2.so"}
  120. {"Garbage collection test 1"
  121. "-shared -binitfini:init_function:fini_function -bE:aix-gc-1.ex"
  122. "" {aix-gc-1.s}
  123. {{objdump {-dz -j.text -j.data} aix-gc-1-SIZE.dd}
  124. {nm {} aix-gc-1-SIZE.nd}}
  125. "aix-gc-1.so"}
  126. {"Glink test 1"
  127. "-shared -bE:aix-glink-1.ex --unresolved-symbols=ignore-all"
  128. "" {aix-glink-1.s}
  129. {{objdump {-D -j.text -j.data} aix-glink-1-SIZE.dd}}
  130. "aix-glink-1.so"}
  131. {"Glink test 2 (part a)" "-shared -bE:aix-glink-2a.ex"
  132. "" {aix-glink-2a.s}
  133. {}
  134. "aix-glink-2a.so"}
  135. {"Glink test 2 (part b)" "-r"
  136. "" {aix-glink-2b.s}
  137. {}
  138. "aix-glink-2b.ro"}
  139. {"Glink test 2 (part c)" "-shared -bE:aix-glink-2c.ex"
  140. "" {aix-glink-2c.s}
  141. {}
  142. "aix-glink-2c.so"}
  143. {"Glink test 2"
  144. "-e.main tmpdir/aix-glink-2a.so tmpdir/aix-glink-2b.ro tmpdir/aix-glink-2c.so"
  145. "" {aix-glink-2d.s}
  146. {{objdump -d aix-glink-2-SIZE.dd}}
  147. "aix-glink-2"}
  148. {"Glink test 3 (shared library a)"
  149. "-shared -bexpall"
  150. "" {aix-glink-3a.s}
  151. {} "aix-glink-3a.so"}
  152. {"Glink test 3 (shared library b)"
  153. "-shared -bexpall"
  154. "" {aix-glink-3b.s}
  155. {} "aix-glink-3b.so"}
  156. {"Glink test 3 (main test)"
  157. "-bnoautoimp tmpdir/aix-glink-3b.so tmpdir/aix-glink-3a.so"
  158. "" {aix-glink-3.s}
  159. {{objdump -d aix-glink-3-SIZE.dd}}
  160. "aix-glink-3"}
  161. {"Line number test 1 (no discards)" "-e.main"
  162. "" {aix-lineno-1.s}
  163. {{objdump -dS aix-lineno-1a-SIZE.dd} {nm {} aix-lineno-1a-SIZE.nd}}
  164. "aix-lineno-1a.exe"}
  165. {"Line number test 1 (discard locals)" "-e.main -x"
  166. "" {aix-lineno-1.s}
  167. {{objdump -dS aix-lineno-1b-SIZE.dd} {nm {} aix-lineno-1b-SIZE.nd}}
  168. "aix-lineno-1b.exe"}
  169. {"Relocatable test 1" "-r"
  170. "" {aix-rel-1.s}
  171. {{objdump -hr aix-rel-1.od}} "aix-rel-1.ro"}
  172. {".ref test 1" "-efoo1"
  173. "" {aix-ref-1.s}
  174. {{objdump -dr aix-ref-1-SIZE.od}}
  175. "aix-ref-1"}
  176. {"Weak test 1 (rel)" "-r"
  177. "" {aix-weak-1a.s aix-weak-1b.s}
  178. {{nm {} aix-weak-1-rel.nd} {objdump -h aix-weak-1-rel.hd}}
  179. "aix-weak-1.o"}
  180. {"Weak test 1 (shared, nogc)" "-shared -bE:aix-weak-1.ex -bnogc"
  181. "" {aix-weak-1a.s aix-weak-1b.s}
  182. {{nm {} aix-weak-1-dso-SIZE.nd} {objdump -h aix-weak-1-dso-SIZE.hd}
  183. {nm -D aix-weak-1-dso-SIZE.dnd}}
  184. "aix-weak-1-nogc.so"}
  185. {"Weak test 1 (shared, gc)" "-shared -bE:aix-weak-1.ex"
  186. "" {aix-weak-1a.s aix-weak-1b.s}
  187. {{nm {} aix-weak-1-gcdso-SIZE.nd} {objdump -h aix-weak-1-gcdso-SIZE.hd}
  188. {nm -D aix-weak-1-gcdso-SIZE.dnd}}
  189. "aix-weak-1-gc.so"}
  190. {"Weak test 2 (library 1)" "-shared -bE:aix-weak-2a.ex"
  191. "" {aix-weak-2a.s}
  192. {{nm -D aix-weak-2a-SIZE.nd}}
  193. "aix-weak-2a.so"}
  194. {"Weak test 2 (library 2)" "-shared -bE:aix-weak-2a.ex"
  195. "" {aix-weak-2b.s}
  196. {{nm -D aix-weak-2b-SIZE.nd}}
  197. "aix-weak-2b.so"}
  198. {"Weak test 2 (main library)"
  199. "-shared -bE:aix-weak-2c.ex tmpdir/aix-weak-2a.so tmpdir/aix-weak-2b.so"
  200. "" {aix-weak-2c.s}
  201. {{nm {} aix-weak-2c-SIZE.nd} {objdump {-sj.data -R} aix-weak-2c-SIZE.od}}
  202. "aix-weak-2c.so"}
  203. {"Weak test 3 (library)" "-shared -bE:aix-weak-3a.ex"
  204. "" {aix-weak-3a.s}
  205. {}
  206. "aix-weak-3a.so"}
  207. {"Weak test 3 (main, dynamic)" "-e.main tmpdir/aix-weak-3a.so"
  208. "" {aix-weak-3b.s}
  209. {{objdump -Dzrj.data aix-weak-3-SIZE.dd}}
  210. "aix-weak-3"}
  211. {"TOC test 1" "-shared -bE:aix-toc-1.ex"
  212. "" {aix-toc-1a.s aix-toc-1b.s}
  213. {{objdump -dr aix-toc-1-SIZE.dd}}
  214. "aix-toc-1.so"}
  215. {"Negative relocation test 1" "-shared -bE:aix-neg-reloc.ex"
  216. "" {aix-neg-reloc.s}
  217. {{objdump -dr aix-neg-reloc-SIZE.d}}
  218. "aix-neg-reloc.so"}
  219. }
  220. foreach test $aix52tests {
  221. foreach { name ldopts asopts sources tools output } $test {
  222. run_aix_test 32 $name $ldopts $asopts $sources $tools $output
  223. run_aix_test 64 $name $ldopts $asopts $sources $tools $output
  224. }
  225. }
  226. run_dump_test "aix-glink-1-32"
  227. run_dump_test "aix-glink-1-64"
  228. run_dump_test "aix-glink-3-32"
  229. run_dump_test "aix-glink-3-64"
  230. run_dump_test "aix-weak-3-32"
  231. run_dump_test "aix-weak-3-64"
  232. # Tests added for features in AIX 7+.
  233. set aix7tests {
  234. {"Large TOC test 1" "-shared -bE:aix-largetoc-1.ex"
  235. "" {aix-largetoc-1.s}
  236. {{objdump -dr aix-largetoc-1-SIZE.d}}
  237. "aix-largetoc-1.so"}
  238. {"TLS relocations" "-shared -bE:aix-tls-reloc.ex"
  239. "" {aix-tls-reloc.s}
  240. {{objdump {-dr -j.data} aix-tls-reloc-SIZE.dd}
  241. {objdump {-dr -j.tdata -j.tbss} aix-tls-reloc-SIZE.dt}}
  242. "aix-tls-reloc.so"}
  243. {"TLS section" "-shared -bE:aix-tls-section.ex"
  244. "" {aix-tls-section.s}
  245. {{objdump -hw aix-tls-section-SIZE.d}}
  246. "aix-tls-section.so"}
  247. }
  248. foreach test $aix7tests {
  249. foreach { name ldopts asopts sources tools output } $test {
  250. run_aix_test 32 $name $ldopts $asopts $sources $tools $output
  251. run_aix_test 64 $name $ldopts $asopts $sources $tools $output
  252. }
  253. }