]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-checks/checks.exp
Use is_xcoff_format in gas testsuite
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-checks / checks.exp
CommitLineData
252b5132 1# Expect script for LD section checks tests
b3adc24a 2# Copyright (C) 1999-2020 Free Software Foundation, Inc.
252b5132 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
252b5132 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
252b5132 9# (at your option) any later version.
f96b4a7b 10#
252b5132
RH
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.
f96b4a7b 15#
252b5132
RH
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.
252b5132
RH
20#
21# Written by Nick Clifton (nickc@cygnus.com)
22
23proc section_check {} {
24 global ld_flags
25 global as
26 global ld
27 global srcdir
28 global subdir
d8045f23 29
ad9f78d1 30 # The usage of .lcomm in asm.s is incompatible with ia64 and ppc coff.
5cd8624d 31 if { [istarget ia64-*-*]
d8045f23
NC
32 || [istarget powerpc*-*-aix*]
33 || [istarget powerpc-*-beos*]
ad9f78d1 34 || [istarget rs6000-*-*] } {
ad995491
L
35 return
36 }
197a7bfd 37 set test "check sections 1"
d8045f23
NC
38
39 set ldflags "--check-sections -e foo"
252b5132
RH
40
41 if { ![ld_assemble $as $srcdir/$subdir/asm.s tmpdir/asm.o]} {
42 unresolved $test
43 return
44 }
45
d9816402 46 if ![ld_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
197a7bfd 47 fail $test
252b5132
RH
48 } else {
49 pass $test
50 }
51
197a7bfd
ILT
52 set test "check sections 2"
53
252b5132
RH
54 # Change the linker flags so that our "buggy" linker
55 # script is used.
56 set ldflags "--check-sections -T $srcdir/$subdir/script -e foo"
57
d9816402 58 # Perform the equivalent of invoking ld_link
d8045f23
NC
59 # except that we need to massage the output further.
60
7f6a71ff 61 set exec_output [run_host_cmd "$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"]
252b5132
RH
62 set exec_output [prune_warnings $exec_output]
63
64 # Make sure that we got some output from the linker
65 if [string match "" $exec_output] then {
197a7bfd 66 fail $test
d8045f23 67 }
252b5132
RH
68
69 # Now remove our expected error message
70 regsub -all ".*: section .data .* overlaps section .text .*" $exec_output "" exec_output
71
72 # And check to see if anything else, (unexpected) was left
73 if [string match "" $exec_output] then {
74 pass $test
75 } else {
76 verbose -log "Unexpected linker message(s): $exec_output"
197a7bfd 77 fail $test
252b5132
RH
78 }
79}
80
d40e34db
TG
81proc overflow_check {} {
82 # Test only on some 32-bit targets that are often tested
83 if { ![istarget i?86-*-*]
84 && ![istarget powerpc-*-*]
85 && ![istarget arm*-*-*] } {
86 return
87 }
9494d963
TG
88 if ![is_elf_format] {
89 return
90 }
d40e34db
TG
91
92 run_dump_test "over"
93 run_dump_test "over2"
94}
95
252b5132 96section_check
d40e34db 97overflow_check