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