]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-checks/checks.exp
2001-02-14 H.J. Lu <hjl@gnu.org>
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-checks / checks.exp
1 # Expect script for LD section checks tests
2 # Copyright (C) 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #
18 # Written by Nick Clifton (nickc@cygnus.com)
19
20 proc section_check {} {
21 global ld_flags
22 global as
23 global ld
24 global srcdir
25 global subdir
26
27 # The usage of .lcomm in asm.s is incompatible with ia64.
28 if { [istarget ia64-*-elf*]
29 || [istarget ia64-*-linux*] } {
30 return
31 }
32 set test "check sections 1"
33
34 set ldflags "--check-sections"
35
36 if { ![ld_assemble $as $srcdir/$subdir/asm.s tmpdir/asm.o]} {
37 unresolved $test
38 return
39 }
40
41 if ![ld_simple_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
42 fail $test
43 } else {
44 pass $test
45 }
46
47 set test "check sections 2"
48
49 # Change the linker flags so that our "buggy" linker
50 # script is used.
51 set ldflags "--check-sections -T $srcdir/$subdir/script -e foo"
52
53 # Perform the equivalent of invoking ld_simple_link
54 # except that we need to massage the output futher.
55
56 catch "exec $ld -o tmpdir/asm.x $ldflags tmpdir/asm.o" exec_output
57 set exec_output [prune_warnings $exec_output]
58
59 # Make sure that we got some output from the linker
60 if [string match "" $exec_output] then {
61 fail $test
62 }
63
64 # Now remove our expected error message
65 regsub -all ".*: section .data .* overlaps section .text .*" $exec_output "" exec_output
66
67 # And check to see if anything else, (unexpected) was left
68 if [string match "" $exec_output] then {
69 pass $test
70 } else {
71 verbose -log "Unexpected linker message(s): $exec_output"
72 fail $test
73 }
74 }
75
76 section_check
77
78