]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-elf/dwarf.exp
gdb/doc: don't have .pod targets separate to man page targets
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / dwarf.exp
1 # Expect script for various DWARF tests.
2 # Copyright (C) 2006-2024 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
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.
10 #
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.
15 #
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.
20 #
21
22 #
23 # Written by H.J. Lu (hongjiu.lu@intel.com)
24 #
25
26 # Exclude non-ELF targets.
27
28 if ![is_elf_format] {
29 return
30 }
31
32 # Skip targets where -shared is not supported
33
34 if ![check_shared_lib_support] {
35 return
36 }
37
38 # Check if compiler works
39 if { ![check_compiler_available] } {
40 return
41 }
42
43 # Skip if -feliminate-dwarf2-dups isn't supported.
44 if ![ld_compile "$CC_FOR_TARGET -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] {
45 return
46 }
47
48 set build_tests {
49 {"Build libdwarf1.so"
50 "-s -shared" "-fPIC -g -feliminate-dwarf2-dups"
51 {dwarf1.c} {} "libdwarf1.so"}
52 {"DWARF parse during linker error"
53 "" "-fno-toplevel-reorder"
54 {dwarf2a.c dwarf2b.c} {{error_output "dwarf2.err"}} "dwarf2.x"}
55 }
56
57 set build_tests_dwarf3 {
58 {"Handle no DWARF information"
59 "" "-g0"
60 {dwarf3.c} {{error_output "dwarf3.err"}} "dwarf3.x"}
61 }
62
63 set run_tests {
64 {"Run with libdwarf1.so first"
65 "-Wl,--no-as-needed tmpdir/libdwarf1.so" ""
66 {dwarf1main.c} "dwarf1a" "dwarf1.out"
67 "-g -feliminate-dwarf2-dups"}
68 {"Run with libdwarf1.so last"
69 "tmpdir/dwarf1main.o tmpdir/libdwarf1.so" ""
70 {dummy.c} "dwarf1b" "dwarf1.out"
71 "-g -feliminate-dwarf2-dups"}
72 }
73
74 # Disable all sanitizers.
75 set old_CFLAGS "$CFLAGS_FOR_TARGET"
76 append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
77 run_cc_link_tests $build_tests
78 setup_xfail loongarch*-*-*
79 run_cc_link_tests $build_tests_dwarf3
80 run_ld_link_exec_tests $run_tests
81 set CFLAGS_FOR_TARGET "$old_CFLAGS"
82
83 proc strip_test {} {
84 global ld
85 global strip
86 global NM
87
88 set test "libdwarf1c.so"
89 set test_name "Strip -s $test"
90 set prog $strip
91
92 if ![ld_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] {
93 fail "$test_name"
94 return
95 }
96
97 send_log "$NM -D tmpdir/$test > tmpdir/$test.exp\n"
98 catch "exec $NM -D tmpdir/$test > tmpdir/$test.exp" got
99 if ![string match "" $got] then {
100 send_log "$got\n"
101 fail "$test_name"
102 return
103 }
104
105 send_log "$prog -s tmpdir/$test\n"
106 catch "exec $prog -s tmpdir/$test" got
107 if ![string match "" $got] then {
108 send_log "$got\n"
109 fail "$test_name"
110 return
111 }
112
113 send_log "$NM -D tmpdir/$test > tmpdir/$test.out\n"
114 catch "exec $NM -D tmpdir/$test > tmpdir/$test.out" got
115 if ![string match "" $got] then {
116 send_log "$got\n"
117 fail "$test_name"
118 return
119 }
120
121 if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
122 send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
123 fail "$test_name"
124 return
125 }
126
127 pass "$test_name"
128 }
129
130 strip_test