1 # Expect script
for LD section checks tests
2 # Copyright
1999, 2001, 2003, 2005, 2007, 2009 Free Software Foundation
, Inc.
4 # This file is part of the GNU Binutils.
6 # This
program is free software
; you can redistribute it and
/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation
; either version
3 of the License
, or
9 #
(at your option
) any later version.
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.
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
18 # Foundation
, Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
,
21 # Written by Nick Clifton
(nickc@cygnus.com
)
23 proc section_check
{} {
30 # The usage of .lcomm in asm.s is incompatible with ia64 and ppc coff.
31 if { [istarget ia64
-*-*]
32 ||
[istarget powerpc
*-*-aix
*]
33 ||
[istarget powerpc
-*-beos
*]
34 ||
[istarget rs6000
-*-*] } {
37 set test
"check sections 1"
39 set ldflags
"--check-sections -e foo"
41 if { ![ld_assemble $as $srcdir
/$subdir
/asm.s tmpdir
/asm.o
]} {
46 if ![ld_simple_link $
ld tmpdir
/asm.x
"$ldflags tmpdir/asm.o"] {
52 set test
"check sections 2"
54 # Change the linker flags so that our
"buggy" linker
56 set ldflags
"--check-sections -T $srcdir/$subdir/script -e foo"
58 # Perform the equivalent of invoking ld_simple_link
59 # except that we need to massage the output further.
61 set exec_output
[run_host_cmd
"$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"]
62 set exec_output
[prune_warnings $exec_output
]
64 # Make sure that we got some output from the linker
65 if [string match
"" $exec_output] then {
69 # Now remove our expected error message
70 regsub
-all
".*: section .data .* overlaps section .text .*" $exec_output "" exec_output
72 # And check to see
if anything
else, (unexpected
) was left
73 if [string match
"" $exec_output] then {
76 verbose
-log "Unexpected linker message(s): $exec_output"