Update release readme after making 2.43.1 release
[binutils-gdb.git] / ld / testsuite / ld-checks / checks.exp
blob5cc2c511e9dd7c646c693eb7fe4bd4e7b5273be6
1 # Expect script for LD section checks tests
2 #   Copyright (C) 1999-2024 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,
19 # MA 02110-1301, USA.
21 # Written by Nick Clifton (nickc@cygnus.com)
23 proc section_check {} {
24     global LDFLAGS
25     global as
26     global ld
27     global srcdir
28     global subdir
30     # The usage of .lcomm in asm.s is incompatible with ia64 and ppc xcoff.
31     if { [istarget ia64-*-*] || [is_xcoff_format] } {
32         return
33     }
34     set test "check sections 1"
36     set ldflags "$LDFLAGS --check-sections -e foo"
38     if { ![ld_assemble $as $srcdir/$subdir/asm.s tmpdir/asm.o]} {
39         unsupported $test
40         return
41     }
43     if ![ld_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
44         fail $test
45     } else {
46         pass $test
47     }
49     set test "check sections 2"
51     # Change the linker flags so that our "buggy" linker
52     # script is used.
53     set ldflags "$LDFLAGS --check-sections -T $srcdir/$subdir/script -e foo"
55     # Perform the equivalent of invoking ld_link
56     # except that we need to massage the output further.
58     set exec_output [run_host_cmd "$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"]
59     set exec_output [prune_warnings $exec_output]
61     # Make sure that we got some output from the linker
62     if [string match "" $exec_output] then {
63         fail $test
64     } else {
66         # Now remove our expected error message
67         regsub -all ".*: section .data .* overlaps section .text .*" $exec_output "" exec_output
69         # And check to see if anything else, (unexpected) was left
70         if [string match "" $exec_output] then {
71             pass $test
72         } else {
73             verbose -log "Unexpected linker message(s): $exec_output"
74             fail $test
75         }
76     }
79 proc overflow_check {} {
80     # Test only on some 32-bit targets that are often tested
81     if { ![istarget i?86-*-*]
82          && ![istarget powerpc-*-*]
83          && ![istarget arm*-*-*] } {
84         return
85     }
86     if ![is_elf_format] {
87         return
88     }
90     run_dump_test "over"
91     run_dump_test "over2"
94 section_check
95 overflow_check