Commit | Line | Data |
---|---|---|
252b5132 | 1 | # Expect script for LD section checks tests |
f96b4a7b | 2 | # Copyright 1999, 2001, 2003, 2007 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 | ||
23 | proc section_check {} { | |
24 | global ld_flags | |
25 | global as | |
26 | global ld | |
27 | global srcdir | |
28 | global subdir | |
29 | ||
ad9f78d1 | 30 | # The usage of .lcomm in asm.s is incompatible with ia64 and ppc coff. |
5cd8624d | 31 | if { [istarget ia64-*-*] |
ad9f78d1 AM |
32 | || [istarget powerpc*-*-aix*] || [istarget powerpc-*-beos*] |
33 | || [istarget rs6000-*-*] } { | |
ad995491 L |
34 | return |
35 | } | |
197a7bfd | 36 | set test "check sections 1" |
252b5132 RH |
37 | |
38 | set ldflags "--check-sections" | |
39 | ||
40 | if { ![ld_assemble $as $srcdir/$subdir/asm.s tmpdir/asm.o]} { | |
41 | unresolved $test | |
42 | return | |
43 | } | |
44 | ||
45 | if ![ld_simple_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] { | |
197a7bfd | 46 | fail $test |
252b5132 RH |
47 | } else { |
48 | pass $test | |
49 | } | |
50 | ||
197a7bfd ILT |
51 | set test "check sections 2" |
52 | ||
252b5132 RH |
53 | # Change the linker flags so that our "buggy" linker |
54 | # script is used. | |
55 | set ldflags "--check-sections -T $srcdir/$subdir/script -e foo" | |
56 | ||
57 | # Perform the equivalent of invoking ld_simple_link | |
58 | # except that we need to massage the output futher. | |
59 | ||
7f6a71ff | 60 | set exec_output [run_host_cmd "$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"] |
252b5132 RH |
61 | set exec_output [prune_warnings $exec_output] |
62 | ||
63 | # Make sure that we got some output from the linker | |
64 | if [string match "" $exec_output] then { | |
197a7bfd | 65 | fail $test |
252b5132 RH |
66 | } |
67 | ||
68 | # Now remove our expected error message | |
69 | regsub -all ".*: section .data .* overlaps section .text .*" $exec_output "" exec_output | |
70 | ||
71 | # And check to see if anything else, (unexpected) was left | |
72 | if [string match "" $exec_output] then { | |
73 | pass $test | |
74 | } else { | |
75 | verbose -log "Unexpected linker message(s): $exec_output" | |
197a7bfd | 76 | fail $test |
252b5132 RH |
77 | } |
78 | } | |
79 | ||
80 | section_check | |
81 | ||
82 |