Don't generate PLT relocations for now binding
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / elf.exp
CommitLineData
782c0ebf 1# Expect script for various ELF tests.
b90efa5b 2# Copyright (C) 2002-2015 Free Software Foundation, Inc.
b7b0b729 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
b7b0b729 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
b7b0b729
HPN
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
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
b7b0b729 20#
b7b0b729
HPN
21
22# Exclude non-ELF targets.
23
43f9d75b 24if ![is_elf_format] {
b7b0b729
HPN
25 return
26}
27
e4970690 28set old_ldflags $LDFLAGS
9f264ea9
AM
29if { [istarget spu*-*-*] } {
30 set LDFLAGS "$LDFLAGS --local-store 0:0"
31}
991cda6c
RH
32if { [istarget alpha*-*-* ] } {
33 # The compress1 test is written expecting 32-bit addresses; force the
34 # executable down into the low address space to match.
35 # ??? How can we adjust just the one testcase?
36 set LDFLAGS "$LDFLAGS -Ttext-segment 0x1000000"
37}
9f264ea9 38
7cf492ee
RM
39if { [istarget "*-*-nacl*"] } {
40 # The eh[1-4] cases are written to expect ELFCLASS64 layout on x86-64.
41 # But the target default is ELFCLASS32. So the cases explicitly use
42 # -melf_x86_64 to select that, but NaCl needs a different emulation name.
43 set options_regsub(ld) {-melf_x86_64 -melf_x86_64_nacl}
44}
45
5cc51864
L
46if { [istarget "*-*-solaris*"] } {
47 # Same for Solaris
48 set options_regsub(ld) {-melf_x86_64 -melf_x86_64_sol2}
49}
50
7f6a71ff
JM
51if { [is_remote host] } then {
52 remote_download host merge.ld
53}
54
5daeae9b
AM
55if { ![istarget hppa64*-hpux*] } {
56 run_ld_link_tests {
57 {"Build symbol3.a"
897aea50 58 "" "" ""
5daeae9b
AM
59 {symbol3.s} {} "symbol3.a"}
60 {"Build symbol3w.a"
897aea50 61 "" "" ""
5daeae9b
AM
62 {symbol3w.s} {} "symbol3w.a"}
63 }
e54e67a9
AM
64
65 if { [check_shared_lib_support] } then {
66 run_ld_link_tests {
897aea50 67 {"Build pr14170a.o" "" "" "" "pr14170a.s" {} "pr14170.a" }
e54e67a9
AM
68 }
69 setup_xfail "tic6x-*-*"
70 run_ld_link_tests {
71 {"Build shared library for pr14170"
897aea50 72 "-shared" "" "" "pr14170b.s" {} "pr14170.so" }
e54e67a9 73 {"PR ld/14170"
897aea50 74 "tmpdir/pr14170a.o tmpdir/pr14170.so" "" "" "pr14170c.s"
e54e67a9
AM
75 { } "pr14170" }
76 }
77 }
83c5d36f
L
78}
79
d215621e 80# Only run these tests on targets thats support creating shared libraries.
1d5316ab 81if { [check_shared_lib_support] } then {
d215621e
AM
82 # Run a test to check linking a shared library with a broken linker
83 # script that accidentally marks dynamic sections as notes. The
84 # resulting executable is not expected to work, but the linker
85 # should not seg-fault whilst creating the binary.
e54e67a9
AM
86 setup_xfail "tic6x-*-*"
87 run_ld_link_tests {
88 {"Build shared library for next test"
897aea50 89 "-shared" "" "" "note-3.s" {} "note-3.so" }
e54e67a9 90 {"Link using broken linker script"
897aea50 91 "--script note-3.t tmpdir/note-3.so" "" "" ""
e54e67a9
AM
92 { { ld "note-3.l" } }
93 "a.out" }
94 }
d215621e
AM
95 setup_xfail "tic6x-*-*"
96 run_ld_link_tests {
97 {"Build pr17068.so"
98 "-shared" "" ""
99 {pr17068d.s} {} "pr17068.so"}
100 {"Build pr17068a.a"
101 "" "" ""
102 {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"}
103 {"Build pr17068b.a"
104 "" "" ""
105 {pr17068b.s pr17068e.s} {} "pr17068b.a"}
106 {"pr17068 link --as-needed lib in group"
107 "--as-needed" "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a --end-group" ""
108 {start.s pr17068.s} {} "pr17068"}
109 }
894891db
NC
110}
111
782c0ebf
AM
112set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
113foreach t $test_list {
114 # We need to strip the ".d", but can leave the dirname.
115 verbose [file rootname $t]
116 run_dump_test [file rootname $t]
117}
24edc24d 118
3ea60775
NC
119# Check that the --warn-orphan option works correctly.
120run_ld_link_tests {
121 {"Report orphan sections"
122 "--script orphan.ld --warn-orphan"
123 ""
124 ""
125 {orphan.s}
126 { { ld "orphan-5.l" } }
127 "orphan"
128 }
129}
130
5940a93c 131if { [istarget *-*-linux*]
5a68afcf 132 || [istarget *-*-nacl*]
5940a93c 133 || [istarget *-*-gnu*] } {
a26587ba
RS
134 run_ld_link_tests {
135 {"Weak symbols in dynamic objects 1 (support)"
897aea50 136 "-shared" "" "" {weak-dyn-1a.s}
a26587ba
RS
137 {}
138 "libweakdyn1a.so"}
139 {"Weak symbols in dynamic objects 1 (main test)"
897aea50 140 "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
a26587ba
RS
141 {{readelf {--relocs --wide} weak-dyn-1.rd}}
142 "libweakdyn1b.so"}
143 }
144}
145
78336cd6
AM
146#v850 gas complains about .tbss.var section attributes.
147if { [check_gc_sections_available] && ![istarget "v850-*-*"] } {
430a16a5
NC
148 run_ld_link_tests {
149 {"--gc-sections on tls variable"
897aea50 150 "--gc-section" "" "" {tls_gc.s} {} "tls_gc"}
430a16a5
NC
151 }
152}
153
6b00ac5a 154if { [istarget *-*-*linux*]
b3adb10f 155 || [istarget *-*-nacl*]
9cc420b6 156 || [istarget *-*-gnu*] } {
04c3a755 157 run_ld_link_tests {
897aea50 158 {"stack exec" "-z execstack" "" "" {stack.s}
04c3a755 159 {{readelf {-Wl} stack-exec.rd}} "stack-exec.exe"}
897aea50 160 {"stack size" "-z stack-size=0x123400" "" "" {stack.s}
04c3a755
NS
161 {{readelf {-Wl} stack-size.rd}} "stack-size.exe"}
162 }
163}
164
e4970690
AM
165set LDFLAGS $old_ldflags
166
24edc24d
L
167# The following tests require running the executable generated by ld.
168if ![isnative] {
169 return
170}
171
a130722b
L
172if [check_gc_sections_available] {
173 run_cc_link_tests {
174 {"PR ld/13195" "-Wl,--gc-sections" ""
175 {pr13195.c} {} "pr13195"}
176 }
54e8959c
L
177}
178
24edc24d
L
179set array_tests {
180 {"preinit array" "" "" {preinit.c} "preinit" "preinit.out"}
24edc24d 181 {"init array" "" "" {init.c} "init" "init.out"}
24edc24d 182 {"fini array" "" "" {fini.c} "fini" "fini.out"}
02ecc8e9 183 {"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
310fd250
L
184}
185set array_tests_pie {
186 {"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" }
187 {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"}
188 {"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"}
189 {"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
11cba4ac 190 {"PIE PR ld/14525" "-pie" "" {pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
5940a93c
TS
191}
192set array_tests_static {
193 {"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"}
194 {"static init array" "-static" "" {init.c} "init" "init.out"}
24edc24d 195 {"static fini array" "-static" "" {fini.c} "fini" "fini.out"}
310fd250 196 {"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
24edc24d
L
197}
198
c8c140d9 199# NetBSD ELF systems do not currently support the .*_array sections.
5940a93c
TS
200set xfails [list "*-*-netbsdelf*"]
201run_ld_link_exec_tests $xfails $array_tests
310fd250 202
3fee20ef 203if { [istarget *-*-linux*]
5a68afcf 204 || [istarget *-*-nacl*]
3fee20ef 205 || [istarget *-*-gnu*] } {
310fd250
L
206 run_ld_link_exec_tests $xfails $array_tests_pie
207}
208
5940a93c
TS
209# Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
210switch -regexp $target_triplet {
211 ^\[^-\]*-\[^-\]*-gnu.*$ {
43fbacde 212 # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>
5940a93c
TS
213 lappend xfails "*-*-*"
214 }
215}
216run_ld_link_exec_tests $xfails $array_tests_static
9ab80182 217
02ecc8e9 218catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status
This page took 0.523505 seconds and 4 git commands to generate.