1# Expect script for ld-powerpc tests 2# Copyright (C) 2002-2016 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 22if { ![istarget "powerpc*-*-*"] } { 23 return 24} 25 26if {[istarget "*-*-vxworks"]} { 27 set ppcvxtests { 28 {"VxWorks shared library test 1 (default script)" "-shared" "" 29 "-mregnames" {vxworks1-lib.s} 30 {{readelf --segments vxworks1-lib.sd}} 31 "libvxworks1.so"} 32 {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" "" 33 "-mregnames" {vxworks1-lib.s} 34 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd} 35 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}} 36 "libvxworks1.so"} 37 {"VxWorks executable test 1 (dynamic)" \ 38 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" "" 39 "-mregnames" {vxworks1.s} 40 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}} 41 "vxworks1"} 42 {"VxWorks executable test 2 (dynamic)" \ 43 "-Tvxworks1.ld -q --force-dynamic" "" 44 "-mregnames" {vxworks2.s} 45 {{readelf --segments vxworks2.sd}} 46 "vxworks2"} 47 {"VxWorks executable test 2 (static)" 48 "-Tvxworks1.ld" "" 49 "-mregnames" {vxworks2.s} 50 {{readelf --segments vxworks2-static.sd}} 51 "vxworks2"} 52 {"VxWorks relax test" 53 "-Tvxworks1.ld --relax -q" "" 54 "-mregnames" {vxworks-relax.s} 55 {{readelf --relocs vxworks-relax.rd}} 56 "vxworks-relax"} 57 {"VxWorks relocatable relax test" 58 "-Tvxworks1.ld -r --relax -q" "" 59 "-mregnames" {vxworks-relax-2.s} 60 {{readelf --relocs vxworks-relax-2.rd}} 61 "vxworks-relax-2"} 62 } 63 run_ld_link_tests $ppcvxtests 64 run_dump_test "vxworks1-static" 65 return 66} 67 68# powerpc ELF only at the moment. Disable for nto too, even though it 69# is ELF, because we pass -melf32ppc to ld and powerpc-nto-ld wants 70# -melf32ppcnto. 71 72if { [istarget "*-*-macos*"] || [istarget "*-*-netware*"] 73 || [istarget "*-*-pe"] || [istarget "*-*-winnt*"] 74 || [istarget "*-*-cygwin*"] || [istarget "*-*-aix*"] 75 || [istarget "*-*-beos*"] || [istarget "*-*-lynxos*"] 76 || [istarget "*-*-nto*"] } { 77 return 78} 79 80proc supports_ppc64 { } { 81 global ld 82 83 catch "exec $ld --help | grep emulations" tmp 84 if [ regexp "elf64l?ppc" $tmp ] then { 85 return 1 86 } else { 87 return 0 88 } 89} 90 91# List contains test-items with 3 items followed by 2 lists: 92# 0:name 1:ld early options 2:ld late options 3:assembler options 93# 4:filenames of assembler files 5: action and options. 6: name of output file 94 95# Actions: 96# objdump: Apply objdump options on result. Compare with regex (last arg). 97# nm: Apply nm options on result. Compare with regex (last arg). 98# readelf: Apply readelf options on result. Compare with regex (last arg). 99 100set ppcelftests { 101 {"Reloc section order" "-melf32ppc -shared -z nocombreloc" "" "-a32" {reloc.s} 102 {{objdump -hw reloc.d}} "reloc.so"} 103 {"APUinfo section processing" "-melf32ppc" "" 104 "-a32 -me500" {apuinfo1.s apuinfo-nul.s apuinfo2.s} 105 {{readelf -x2 apuinfo.rd}} "apuinfo"} 106 {"APUinfo VLE section processing" "-melf32ppc" "" 107 "-a32 -me500 -mvle" {apuinfo1.s apuinfo-vle.s apuinfo-vle2.s} 108 {{readelf -x2 apuinfo-vle.rd}} "apuinfo-vle"} 109 {"APUinfo NULL section processing" "-melf32ppc" "" 110 "-a32 -me500" {apuinfo-nul1.s apuinfo-nul.s} 111 {{readelf -x2 apuinfo-nul.rd}} "apuinfo"} 112 {"TLS32 static exec" "-melf32ppc" "" "-a32" {tls32.s tlslib32.s} 113 {{objdump -dr tls32.d} {objdump -sj.got tls32.g} 114 {objdump -sj.tdata tls32.t}} 115 "tls32"} 116 {"TLS32 helper shared library" "-shared -melf32ppc tmpdir/tlslib32.o" "" "" {} 117 {} "libtlslib32.so"} 118 {"TLS32 dynamic exec" "-melf32ppc --no-ld-generated-unwind-info tmpdir/tls32.o tmpdir/libtlslib32.so" "" "" {} 119 {{readelf -WSsrl tlsexe32.r} {objdump -dr tlsexe32.d} 120 {objdump -sj.got tlsexe32.g} {objdump -sj.tdata tlsexe32.t}} 121 "tlsexe32"} 122 {"TLS32 shared" "-shared -melf32ppc --no-ld-generated-unwind-info tmpdir/tls32.o" "" "" {} 123 {{readelf -WSsrl tlsso32.r} {objdump -dr tlsso32.d} 124 {objdump -sj.got tlsso32.g} {objdump -sj.tdata tlsso32.t}} 125 "tls32.so"} 126 {"TLS32 markers" "-melf32ppc" "" "-a32" {tlsmark32.s tlslib32.s} 127 {{objdump -dr tlsmark32.d}} 128 "tlsmark32"} 129 {"TLS32 opt 1" "-melf32ppc" "" "-a32" {tlsopt1_32.s tlslib32.s} 130 {{objdump -dr tlsopt1_32.d}} 131 "tlsopt1_32"} 132 {"TLS32 opt 2" "-melf32ppc" "" "-a32" {tlsopt2_32.s tlslib32.s} 133 {{objdump -dr tlsopt2_32.d}} 134 "tlsopt2_32"} 135 {"TLS32 opt 3" "-melf32ppc" "" "-a32" {tlsopt3_32.s tlslib32.s} 136 {{objdump -dr tlsopt3_32.d}} 137 "tlsopt3_32"} 138 {"TLS32 opt 4" "-melf32ppc" "" "-a32" {tlsopt4_32.s tlslib32.s} 139 {{objdump -dr tlsopt4_32.d}} 140 "tlsopt4_32"} 141 {"TLS32 DLL" "-shared -melf32ppc --version-script tlsdll.ver" "" "-a32" {tlsdll_32.s} 142 {} "tlsdll32.so"} 143 {"TLS32 opt 5" "-melf32ppc --gc-sections --secure-plt tmpdir/tlsdll32.so" "" "-a32" {tlsopt5_32.s} 144 {{objdump -dr tlsopt5_32.d}} 145 "tlsopt5_32"} 146 {"Shared library with global symbol" "-shared -melf32ppc" "" "-a32" {sdalib.s} 147 {} "sdalib.so"} 148 {"Dynamic application with SDA" "-melf32ppc tmpdir/sdalib.so" "" "-a32" {sdadyn.s} 149 {{objdump -R sdadyn.d}} "sdadyn"} 150 {"relaxing" "-melf32ppc --relax -Ttext=0 --defsym far=0x80001234 --defsym near=0x00004320" "" "-a32" "relax.s" 151 {{objdump -dr relax.d}} 152 "relax"} 153 {"relocatable relaxing" "-melf32ppc -r --relax" "" "-a32" "relax.s" 154 {{objdump -dr relaxr.d}} 155 "relax"} 156} 157 158set ppc64elftests { 159 {"TLS static exec" "-melf64ppc" "" "-a64" {tls.s tlslib.s} 160 {{objdump -dr tls.d} {objdump -sj.got tls.g} {objdump -sj.tdata tls.t}} 161 "tls"} 162 {"TLS helper shared library" "-shared -melf64ppc tmpdir/tlslib.o" "" "" {} 163 {} "libtlslib.so"} 164 {"TLS helper old shared lib" "-shared -melf64ppc" "" "-a64" {oldtlslib.s} 165 {} "liboldlib.so"} 166 {"TLS dynamic exec" "-melf64ppc --no-ld-generated-unwind-info tmpdir/tls.o tmpdir/libtlslib.so" "" "" {} 167 {{readelf -WSsrl tlsexe.r} {objdump -dr tlsexe.d} 168 {objdump -sj.got tlsexe.g} {objdump -sj.tdata tlsexe.t}} 169 "tlsexe"} 170 {"TLS dynamic old" "-melf64ppc --no-ld-generated-unwind-info tmpdir/tls.o tmpdir/liboldlib.so" "" "" {} 171 {{readelf -WSsrl tlsexe.r} {objdump -dr tlsexe.d} 172 {objdump -sj.got tlsexe.g} {objdump -sj.tdata tlsexe.t}} 173 "tlsexeold"} 174 {"TLS shared" "-shared -melf64ppc --no-ld-generated-unwind-info tmpdir/tls.o" "" "" {} 175 {{readelf -WSsrl tlsso.r} {objdump -dr tlsso.d} 176 {objdump -sj.got tlsso.g} {objdump -sj.tdata tlsso.t}} 177 "tls.so"} 178 {"TLSTOC static exec" "-melf64ppc tmpdir/tlslib.o " "" "-a64" {tlstoc.s} 179 {{objdump -dr tlstoc.d} {objdump -sj.got tlstoc.g} 180 {objdump -sj.tdata tlstoc.t}} 181 "tlstoc"} 182 {"TLSTOC dynamic exec" "-melf64ppc --no-ld-generated-unwind-info tmpdir/tlstoc.o tmpdir/libtlslib.so" "" 183 "" {} 184 {{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d} 185 {objdump -sj.got tlsexetoc.g} {objdump -sj.tdata tlsexetoc.t}} 186 "tlsexetoc"} 187 {"TLSTOC dynamic old" "-melf64ppc --no-ld-generated-unwind-info tmpdir/tlstoc.o tmpdir/liboldlib.so" "" 188 "" {} 189 {{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d} 190 {objdump -sj.got tlsexetoc.g} {objdump -sj.tdata tlsexetoc.t}} 191 "tlsexetocold"} 192 {"TLSTOC shared" "-shared -melf64ppc --no-ld-generated-unwind-info tmpdir/tlstoc.o" "" "" {} 193 {{readelf -WSsrl tlstocso.r} {objdump -dr tlstocso.d} 194 {objdump -sj.got tlstocso.g} {objdump -sj.tdata tlstocso.t}} 195 "tlstoc.so"} 196 {"TLS markers" "-melf64ppc" "" "-a64" {tlsmark.s tlslib.s} 197 {{objdump -dr tlsmark.d}} 198 "tlsmark"} 199 {"TLS opt 1" "-melf64ppc" "" "-a64" {tlsopt1.s tlslib.s} 200 {{objdump -dr tlsopt1.d}} 201 "tlsopt1"} 202 {"TLS opt 2" "-melf64ppc" "" "-a64" {tlsopt2.s tlslib.s} 203 {{objdump -dr tlsopt2.d}} 204 "tlsopt2"} 205 {"TLS opt 3" "-melf64ppc" "" "-a64" {tlsopt3.s tlslib.s} 206 {{objdump -dr tlsopt3.d}} 207 "tlsopt3"} 208 {"TLS opt 4" "-melf64ppc" "" "-a64" {tlsopt4.s tlslib.s} 209 {{objdump -dr tlsopt4.d}} 210 "tlsopt4"} 211 {"TLS DLL" "-shared -melf64ppc --version-script tlsdll.ver" "" "-a64" {tlsdll.s} 212 {} "tlsdll.so"} 213 {"TLS opt 5" "-melf64ppc --gc-sections tmpdir/tlsdll.so" "" "-a64" {tlsopt5.s} 214 {{objdump -dr tlsopt5.d}} 215 "tlsopt5"} 216 {"sym@tocbase" "-shared -melf64ppc" "" "-a64" {symtocbase-1.s symtocbase-2.s} 217 {{objdump -dj.data symtocbase.d}} "symtocbase.so"} 218 {"TOC opt" "-melf64ppc" "" "-a64" {tocopt.s} 219 {{ld tocopt.out} {objdump -s tocopt.d}} "tocopt"} 220 {"TOC opt2" "-melf64ppc --defsym x=2" "" "-a64" {tocopt2.s} 221 {{ld tocopt2.out} {objdump -s tocopt2.d}} "tocopt2"} 222 {"TOC opt3" "-melf64ppc -no-keep-memory --defsym x=2" "" "-a64" {tocopt3.s} 223 {{objdump -s tocopt3.d}} "tocopt3"} 224 {"TOC opt4" "-melf64ppc -no-keep-memory --defsym x=2" "" "-a64" 225 {tocopt4a.s tocopt4b.s} {{objdump -s tocopt4.d}} "tocopt4"} 226 {"TOC opt5" "-melf64ppc" "" "-a64" {tocopt5.s} 227 {{objdump -s tocopt5.d}} "tocopt5"} 228 {"TOC opt6" "-melf64ppc" "" "-a64" {tocopt6a.s tocopt6b.s tocopt6c.s} 229 {{objdump -d tocopt6.d}} "tocopt6"} 230 {"TOC opt7" "-melf64ppc" "" "-a64 -mpower9" {tocopt7.s} 231 {{ld tocopt7.out} {objdump -s tocopt7.d}} "tocopt7"} 232 {"TOC opt8" "-melf64ppc" "" "-a64 -mpower9" {tocopt8.s} 233 {{objdump -s tocopt8.d}} "tocopt8"} 234 {"ambig shared v1" "-shared -melf64ppc" "" "-a64" {funv1.s} {} "funv1.so"} 235 {"ambig shared v2" "-shared -melf64ppc" "" "-a64" {funv2.s} {} "funv2.so"} 236} 237 238set ppceabitests { 239 {"VLE multiple segments 1" "-T vle-multiseg-1.ld" "" 240 "-mregnames -mvle" {vle-multiseg.s} 241 {{readelf "-l" vle-multiseg-1.d}} "vle-multiseg-1"} 242 {"VLE multiple segments 2" "-T vle-multiseg-2.ld" "" 243 "-mregnames -mvle" {vle-multiseg.s} 244 {{readelf "-l" vle-multiseg-2.d}} "vle-multiseg-2"} 245 {"VLE multiple segments 3" "-T vle-multiseg-3.ld" "" 246 "-mregnames -mvle" {vle-multiseg.s} 247 {{readelf "-l" vle-multiseg-3.d}} "vle-multiseg-3"} 248 {"VLE multiple segments 4" "-T vle-multiseg-4.ld" "" 249 "-mregnames -mvle" {vle-multiseg.s} 250 {{readelf "-l" vle-multiseg-4.d}} "vle-multiseg-4"} 251 {"VLE multiple segments 5" "-T vle-multiseg-5.ld" "" 252 "-mregnames -mvle" {vle-multiseg.s} 253 {{readelf "-l" vle-multiseg-5.d}} "vle-multiseg-5"} 254 {"VLE relocations 1" "-T vle.ld" "" 255 "-mvle" {vle-reloc-1.s vle-reloc-def-1.s} 256 {{objdump "-Mvle -d" vle-reloc-1.d}} "vle-reloc-1"} 257 {"VLE relocations 2" "-T vle.ld" "" 258 "-mvle" {vle-reloc-2.s vle-reloc-def-2.s} 259 {{objdump "-Mvle -d" vle-reloc-2.d}} "vle-reloc-2"} 260 {"VLE relocations 3" "-T vle.ld" "" 261 "-mvle" {vle-reloc-3.s vle-reloc-def-3.s} 262 {{objdump "-Mvle -d" vle-reloc-3.d}} "vle-reloc-3"} 263} 264 265if [istarget "powerpc*le*-*-*"] then { 266 set options_regsub(ld) {{-melf([3264]*)ppc} {-melf\1lppc}} 267 268 for {set i 0} {$i < [llength $ppcelftests]} {incr i} { 269 set line [lindex $ppcelftests $i] 270 set ld_options [lindex $line 1] 271 regsub -all elf32ppc $ld_options elf32lppc ld_options 272 set line [lreplace $line 1 1 $ld_options] 273 set ppcelftests [lreplace $ppcelftests $i $i $line] 274 } 275 276 if [ supports_ppc64 ] then { 277 for {set i 0} {$i < [llength $ppc64elftests]} {incr i} { 278 set line [lindex $ppc64elftests $i] 279 set ld_options [lindex $line 1] 280 regsub -all elf64ppc $ld_options elf64lppc ld_options 281 set line [lreplace $line 1 1 $ld_options] 282 set ppc64elftests [lreplace $ppc64elftests $i $i $line] 283 } 284 } 285} 286 287run_ld_link_tests $ppcelftests 288 289if [ supports_ppc64 ] then { 290 run_ld_link_tests $ppc64elftests 291 run_dump_test "relbrlt" 292 run_dump_test "elfv2so" 293 run_dump_test "elfv2exe" 294 run_dump_test "elfv2-2so" 295 run_dump_test "elfv2-2exe" 296 run_dump_test "ambiguousv1" 297 run_dump_test "ambiguousv1b" 298 run_dump_test "ambiguousv2" 299 run_dump_test "ambiguousv2b" 300 run_dump_test "defsym" 301 run_dump_test "tocvar" 302 run_dump_test "tocnovar" 303 run_dump_test "tlsld" 304 run_dump_test "relocsort" 305 run_dump_test "addpcis" 306} 307 308run_dump_test "tlsld32" 309 310if { [istarget "powerpc*-eabi*"] } { 311 run_ld_link_tests $ppceabitests 312} 313 314run_dump_test "plt1" 315run_dump_test "sdabase" 316run_dump_test "sdabase2" 317 318run_dump_test "attr-gnu-4-00" 319run_dump_test "attr-gnu-4-01" 320run_dump_test "attr-gnu-4-02" 321run_dump_test "attr-gnu-4-03" 322run_dump_test "attr-gnu-4-10" 323run_dump_test "attr-gnu-4-11" 324run_dump_test "attr-gnu-4-12" 325run_dump_test "attr-gnu-4-13" 326run_dump_test "attr-gnu-4-20" 327run_dump_test "attr-gnu-4-21" 328run_dump_test "attr-gnu-4-22" 329run_dump_test "attr-gnu-4-23" 330run_dump_test "attr-gnu-4-31" 331run_dump_test "attr-gnu-4-32" 332run_dump_test "attr-gnu-4-33" 333 334run_dump_test "attr-gnu-8-11" 335run_dump_test "attr-gnu-8-23" 336run_dump_test "attr-gnu-8-31" 337 338run_dump_test "attr-gnu-12-11" 339run_dump_test "attr-gnu-12-21" 340 341run_dump_test "vle-multiseg-6" 342 343run_dump_test "ppc476-shared" 344run_dump_test "ppc476-shared2" 345