Commit | Line | Data |
---|---|---|
782c0ebf | 1 | # Expect script for various ELF tests. |
5daeae9b AM |
2 | # Copyright 2002, 2003, 2005, 2007, 2009, 2010, 2011 |
3 | # Free Software Foundation, Inc. | |
b7b0b729 | 4 | # |
f96b4a7b NC |
5 | # This file is part of the GNU Binutils. |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
b7b0b729 | 8 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 9 | # the Free Software Foundation; either version 3 of the License, or |
b7b0b729 HPN |
10 | # (at your option) any later version. |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
19 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | # MA 02110-1301, USA. | |
b7b0b729 | 21 | # |
b7b0b729 HPN |
22 | |
23 | # Exclude non-ELF targets. | |
24 | ||
43f9d75b | 25 | if ![is_elf_format] { |
b7b0b729 HPN |
26 | return |
27 | } | |
28 | ||
e4970690 | 29 | set old_ldflags $LDFLAGS |
9f264ea9 AM |
30 | if { [istarget spu*-*-*] } { |
31 | set LDFLAGS "$LDFLAGS --local-store 0:0" | |
32 | } | |
991cda6c RH |
33 | if { [istarget alpha*-*-* ] } { |
34 | # The compress1 test is written expecting 32-bit addresses; force the | |
35 | # executable down into the low address space to match. | |
36 | # ??? How can we adjust just the one testcase? | |
37 | set LDFLAGS "$LDFLAGS -Ttext-segment 0x1000000" | |
38 | } | |
9f264ea9 | 39 | |
7f6a71ff JM |
40 | if { [is_remote host] } then { |
41 | remote_download host merge.ld | |
42 | } | |
43 | ||
5daeae9b AM |
44 | if { ![istarget hppa64*-hpux*] } { |
45 | run_ld_link_tests { | |
46 | {"Build symbol3.a" | |
47 | "" "" | |
48 | {symbol3.s} {} "symbol3.a"} | |
49 | {"Build symbol3w.a" | |
50 | "" "" | |
51 | {symbol3w.s} {} "symbol3w.a"} | |
52 | } | |
83c5d36f L |
53 | } |
54 | ||
894891db NC |
55 | # Run a test to check linking a shared library with a broken linker |
56 | # script that accidentally marks dynamic sections as notes. The | |
57 | # resulting executable is not expected to work, but the linker | |
58 | # should not seg-fault whilst creating the binary. | |
59 | # | |
60 | # Only run the test on targets thats support creating shared libraries. | |
61 | if { ! [istarget arc-*-*] | |
62 | && ! [istarget avr-*-*] | |
63 | && ! [istarget cr16-*-*] | |
64 | && ! [istarget cris*-*-*] | |
65 | && ! [istarget crx-*-*] | |
66 | && ! [istarget d10v-*-*] | |
67 | && ! [istarget d30v-*-*] | |
68 | && ! [istarget dlx-*-*] | |
69 | && ! [istarget fr30-*-*] | |
70 | && ! [istarget frv-*-*] | |
71 | && ! [istarget h8300-*-*] | |
daceadb8 AM |
72 | && ! [istarget i860-*-*] |
73 | && ! [istarget i960-*-*] | |
894891db | 74 | && ! [istarget ip2k-*-*] |
daceadb8 AM |
75 | && ! [istarget iq2000-*-*] |
76 | && ! [istarget lm32-*-*] | |
77 | && ! [istarget m32c-*-*] | |
894891db NC |
78 | && ! [istarget m32r-*-*] |
79 | && ! [istarget mcore*-*-*] | |
daceadb8 AM |
80 | && ! [istarget mep-*-*] |
81 | && ! [istarget microblaze-*-*] | |
894891db | 82 | && ! [istarget mn10200-*-*] |
daceadb8 AM |
83 | && ! [istarget moxie-*-*] |
84 | && ! [istarget ms1-*-*] | |
894891db NC |
85 | && ! [istarget msp430-*-*] |
86 | && ! [istarget openrisc-*-*] | |
87 | && ! [istarget or32-*-*] | |
88 | && ! [istarget pj-*-*] | |
89 | && ! [istarget rx-*-*] | |
daceadb8 | 90 | && ! [istarget spu-*-*] |
840c4ae9 | 91 | && ! [istarget v850*-*-*] |
daceadb8 | 92 | && ! [istarget xstormy16-*-*] |
894891db NC |
93 | && ! [istarget *-*-irix*] |
94 | && ! [istarget *-*-rtems] } { | |
95 | run_ld_link_tests { | |
96 | {"Build shared library for next test" | |
97 | "-shared" "" "note-3.s" {} "note-3.so" } | |
98 | {"Link using broken linker script" | |
99 | "--script note-3.t tmpdir/note-3.so" "" "" | |
100 | { { ld "note-3.l" } } | |
101 | "a.out" } | |
102 | } | |
103 | } | |
104 | ||
782c0ebf AM |
105 | set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] |
106 | foreach t $test_list { | |
107 | # We need to strip the ".d", but can leave the dirname. | |
108 | verbose [file rootname $t] | |
109 | run_dump_test [file rootname $t] | |
110 | } | |
24edc24d | 111 | |
5940a93c TS |
112 | if { [istarget *-*-linux*] |
113 | || [istarget *-*-gnu*] } { | |
a26587ba RS |
114 | run_ld_link_tests { |
115 | {"Weak symbols in dynamic objects 1 (support)" | |
116 | "-shared" "" {weak-dyn-1a.s} | |
117 | {} | |
118 | "libweakdyn1a.so"} | |
119 | {"Weak symbols in dynamic objects 1 (main test)" | |
120 | "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" {weak-dyn-1b.s} | |
121 | {{readelf {--relocs --wide} weak-dyn-1.rd}} | |
122 | "libweakdyn1b.so"} | |
123 | } | |
124 | } | |
125 | ||
78336cd6 AM |
126 | #v850 gas complains about .tbss.var section attributes. |
127 | if { [check_gc_sections_available] && ![istarget "v850-*-*"] } { | |
430a16a5 NC |
128 | run_ld_link_tests { |
129 | {"--gc-sections on tls variable" | |
130 | "--gc-section" "" {tls_gc.s} {} "tls_gc"} | |
131 | } | |
132 | } | |
133 | ||
e4970690 AM |
134 | set LDFLAGS $old_ldflags |
135 | ||
24edc24d L |
136 | # The following tests require running the executable generated by ld. |
137 | if ![isnative] { | |
138 | return | |
139 | } | |
140 | ||
54e8959c L |
141 | run_cc_link_tests { |
142 | {"PR ld/13195" "-Wl,--gc-sections" "" | |
143 | {pr13195.c} {} "pr13195"} | |
144 | } | |
145 | ||
24edc24d L |
146 | set array_tests { |
147 | {"preinit array" "" "" {preinit.c} "preinit" "preinit.out"} | |
24edc24d | 148 | {"init array" "" "" {init.c} "init" "init.out"} |
24edc24d | 149 | {"fini array" "" "" {fini.c} "fini" "fini.out"} |
02ecc8e9 | 150 | {"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."} |
310fd250 L |
151 | } |
152 | set array_tests_pie { | |
153 | {"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" } | |
154 | {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"} | |
155 | {"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"} | |
156 | {"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"} | |
5940a93c TS |
157 | } |
158 | set array_tests_static { | |
159 | {"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"} | |
160 | {"static init array" "-static" "" {init.c} "init" "init.out"} | |
24edc24d | 161 | {"static fini array" "-static" "" {fini.c} "fini" "fini.out"} |
310fd250 | 162 | {"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."} |
24edc24d L |
163 | } |
164 | ||
c8c140d9 | 165 | # NetBSD ELF systems do not currently support the .*_array sections. |
5940a93c TS |
166 | set xfails [list "*-*-netbsdelf*"] |
167 | run_ld_link_exec_tests $xfails $array_tests | |
310fd250 | 168 | |
3fee20ef TS |
169 | if { [istarget *-*-linux*] |
170 | || [istarget *-*-gnu*] } { | |
310fd250 L |
171 | run_ld_link_exec_tests $xfails $array_tests_pie |
172 | } | |
173 | ||
5940a93c TS |
174 | # Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc. |
175 | switch -regexp $target_triplet { | |
176 | ^\[^-\]*-\[^-\]*-gnu.*$ { | |
43fbacde | 177 | # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static> |
5940a93c TS |
178 | lappend xfails "*-*-*" |
179 | } | |
180 | } | |
181 | run_ld_link_exec_tests $xfails $array_tests_static | |
9ab80182 | 182 | |
02ecc8e9 | 183 | catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status |