ld/testsuite/
[external/binutils.git] / ld / testsuite / ld-sparc / sparc.exp
1 # Expect script for ld-sparc tests
2 #   Copyright (C) 2002, 2003, 2005 Free Software Foundation
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
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, MA 02110-1301, USA.
17 #
18
19 # Test SPARC linking; all types of relocs.  This tests the assembler and
20 # tools like objdump as well as the linker.
21
22 if {[istarget "sparc-*-vxworks"]} {
23     set sparcvxworkstests {
24         {"VxWorks shared library test 1" "-shared -Tvxworks1.ld"
25          "-KPIC" {vxworks1-lib.s}
26          {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
27           {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
28          "libvxworks1.so"}
29         {"VxWorks executable test 1 (dynamic)" \
30          "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic"
31          "" {vxworks1.s}
32          {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
33          "vxworks1"}
34         {"VxWorks executable test 2 (dynamic)" \
35          "-Tvxworks1.ld -q --force-dynamic"
36          "" {vxworks2.s}
37          {{readelf --segments vxworks2.sd}}
38          "vxworks2"}
39         {"VxWorks executable test 2 (static)"
40          "-Tvxworks1.ld"
41          "" {vxworks2.s}
42          {{readelf --segments vxworks2-static.sd}}
43          "vxworks2"}
44     }
45     run_ld_link_tests $sparcvxworkstests
46     run_dump_test "vxworks1-static"
47 }
48
49 if { !([istarget "sparc*-*-elf*"]
50        || [istarget "sparc*-sun-solaris*"]
51        || ([istarget "sparc*-*-linux*"]
52            && ![istarget "*-*-*aout*"]
53            && ![istarget "*-*-*oldld*"])) } {
54     return
55 }
56
57 # List contains test-items with 3 items followed by 2 lists:
58 # 0:name 1:ld options 2:assembler options
59 # 3:filenames of assembler files 4: action and options. 5: name of output file
60
61 # Actions:
62 # objdump: Apply objdump options on result.  Compare with regex (last arg).
63 # nm: Apply nm options on result.  Compare with regex (last arg).
64 # readelf: Apply readelf options on result.  Compare with regex (last arg).
65
66 set sparctests {
67     {"32-bit: TLS -fpic -shared transitions" "-shared -melf32_sparc"
68      "--32 -K PIC" {tlssunpic32.s tlspic.s}
69      {{readelf -WSsrl tlssunpic32.rd} {objdump -drj.text tlssunpic32.dd}
70       {objdump -sj.got tlssunpic32.sd} {objdump -sj.tdata tlssunpic32.td}}
71       "libtlssunpic32.so"}
72     {"32-bit: Helper shared library" "-shared -melf32_sparc"
73      "--32 -K PIC" {tlslib.s} {} "libtlslib32.so"}
74     {"32-bit: Another helper shared library" "-shared -melf32_sparc"
75      "--32 -K PIC" {tlssunbinpic32.s} {} "libtlssunbinpic32.so"}
76     {"32-bit: TLS -fpic and -fno-pic exec transitions"
77      "-melf32_sparc tmpdir/libtlslib32.so tmpdir/tlssunbinpic32.o"
78      "--32" {tlssunbin32.s}
79      {{readelf -WSsrl tlssunbin32.rd} {objdump -drj.text tlssunbin32.dd}
80       {objdump -sj.got tlssunbin32.sd} {objdump -sj.tdata tlssunbin32.td}}
81       "tlssunbin32"}
82     {"32-bit: TLS -fno-pic -shared" "-shared -melf32_sparc"
83      "--32" {tlssunnopic32.s tlsnopic.s}
84      {{readelf -WSsrl tlssunnopic32.rd} {objdump -drj.text tlssunnopic32.dd}
85       {objdump -sj.got tlssunnopic32.sd}} "libtlssunnopic32.so"}
86     {"32-bit: TLS in debug sections" "-melf32_sparc"
87      "--32" {tlsg32.s}
88      {{objdump -sj.debug_foobar tlsg32.sd}} "tlsg32"}
89 }
90 set sparc64tests {
91     {"64-bit: TLS -fpic -shared transitions" "-shared -melf64_sparc"
92      "--64 -Av9 -K PIC" {tlssunpic64.s tlspic.s}
93      {{readelf -WSsrl tlssunpic64.rd} {objdump -drj.text tlssunpic64.dd}
94       {objdump -sj.got tlssunpic64.sd} {objdump -sj.tdata tlssunpic64.td}}
95       "libtlssunpic64.so"}
96     {"64-bit: Helper shared library" "-shared -melf64_sparc"
97      "--64 -Av9 -K PIC" {tlslib.s} {} "libtlslib64.so"}
98     {"64-bit: Another helper shared library" "-shared -melf64_sparc"
99      "--64 -Av9 -K PIC" {tlssunbinpic64.s} {} "libtlssunbinpic64.so"}
100     {"64-bit: TLS -fpic and -fno-pic exec transitions"
101      "-melf64_sparc tmpdir/libtlslib64.so tmpdir/tlssunbinpic64.o"
102      "--64 -Av9" {tlssunbin64.s}
103      {{readelf -WSsrl tlssunbin64.rd} {objdump -drj.text tlssunbin64.dd}
104       {objdump -sj.got tlssunbin64.sd} {objdump -sj.tdata tlssunbin64.td}}
105       "tlssunbin64"}
106     {"64-bit: TLS -fno-pic -shared" "-shared -melf64_sparc"
107      "--64 -Av9" {tlssunnopic64.s tlsnopic.s}
108      {{readelf -WSsrl tlssunnopic64.rd} {objdump -drj.text tlssunnopic64.dd}
109       {objdump -sj.got tlssunnopic64.sd}} "libtlssunnopic64.so"}
110     {"64-bit: TLS in debug sections" "-melf64_sparc"
111      "--64 -Av9" {tlsg64.s}
112      {{objdump -sj.debug_foobar tlsg64.sd}} "tlsg64"}
113 }
114
115 if { ![istarget "sparc64-*-elf*"] } {
116     run_ld_link_tests $sparctests
117 }
118 if { !([istarget "sparc-*-elf*"]
119        || [istarget "sparc-sun-solaris2.5*"]
120        || [istarget "sparc-sun-solaris2.6"]) } {
121     run_ld_link_tests $sparc64tests
122 }