]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/testsuite/gas/elf/elf.exp
Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / elf / elf.exp
CommitLineData
b90efa5b 1# Copyright (C) 2012-2015 Free Software Foundation, Inc.
5bf135a7
NC
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
98944905
RH
17#
18# elf tests
19#
20
dfeb0666 21proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
5b5032eb
L
22 global READELF
23 global srcdir subdir
24 set testname "elf $name list"
02e07694 25 set file $srcdir/$subdir/$name
5b5032eb 26 gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
5c1aa77e 27 if { ![string match "" $opts]
eb22018c 28 && [regexp_diff "dump.out" "${file}.l"] } then {
5b5032eb
L
29 fail $testname
30 verbose "output is [file_contents "dump.out"]" 2
31 return
32 }
7a6d0b32 33 send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
7f6a71ff
JM
34 set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"]
35 if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then {
36 send_log "[lindex $status 1]\n"
37 fail $testname
38 return
39 }
40 catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output
5b5032eb
L
41 if ![string match "" $comp_output] then {
42 send_log "$comp_output\n"
43 fail $testname
44 return
45 }
46 verbose_eval {[file_contents "dump.out"]} 3
eb22018c 47 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
5b5032eb
L
48 fail $testname
49 verbose "output is [file_contents "dump.out"]" 2
50 return
51 }
52 pass $testname
53}
54
98944905 55# We're testing bits in obj-elf -- don't run on anything else.
017761ea 56if { [is_elf_format] } then {
fa6b2d59 57 set target_machine ""
9e0665bc 58 if {[istarget "mips*-*-*"]} then {
fa6b2d59
L
59 set target_machine -mips
60 }
6a7715f4
NC
61 if {[istarget m32r*-*-*]} then {
62 set target_machine -m32r
63 }
13761a11
NC
64 if {[istarget "msp430-*-*"]} then {
65 set target_machine -msp430
66 }
1c0d3aa6
NC
67 if {[istarget "score-*-*"]} then {
68 set target_machine -score
69 }
59e6276b
JM
70 if {[istarget "tic6x-*-*"]} then {
71 set target_machine -tic6x
72 }
f8a52b59 73 if {[istarget "xtensa*-*-*"]} then {
2caa7ca0
BW
74 set target_machine -xtensa
75 }
c7927a3c
NC
76 if {[istarget "rx-*-*"]} then {
77 set target_machine -rx
78 }
685080f2
NC
79 if {[istarget "v850*-*-*"]} then {
80 set target_machine -v850
81 }
8c5fc800 82 if {[istarget "arm*-*-*"]} {
0b42baa3 83 set target_machine -arm
ee065d83 84 }
8c750480 85
ee6365aa
BW
86 # The MN10300 and Xtensa ports disable the assembler's call frame
87 # optimization because it interfers with link-time relaxation of
88 # function prologues.
89 if {![istarget "mn10300-*-*"]
90 && ![istarget "xtensa*-*-*"]
13761a11 91 && ![istarget "msp430*-*-*"]
35c08157 92 && ![istarget "nds32*-*-*"]
01642c12 93 && ![istarget "am3*-*-*"]} then {
8c750480
NC
94 run_dump_test "ehopt0"
95 }
efa19bfd
JB
96 case $target_triplet in {
97 { m68k-*-* m68[03]??-*-* } {
98 run_dump_test "file" { { as "--defsym m68k=1" } }
99 }
100 { mmix-*-* } {
101 run_dump_test "file" { { as "--defsym mmix=1" } }
102 }
103 { xtensa*-*-* } {
104 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
105 }
106 default {
107 run_dump_test "file"
108 }
109 }
35c08157 110 setup_xfail "nds32*-*-*"
01642c12
RM
111 run_dump_test "group0a"
112 run_dump_test "group0b"
709001e9 113 run_dump_test "group0c"
01642c12
RM
114 run_dump_test "group1a"
115 run_dump_test "group1b"
5f3fd8b4 116 run_dump_test "group2"
5ff3e4be 117 case $target_triplet in {
516e75be
AM
118 { hppa64*-*-hpux* } { }
119 default {
120 run_dump_test "groupautoa"
121 }
122 }
123 case $target_triplet in {
124 { hppa64*-*-hpux* } { }
5ff3e4be
AM
125 { xtensa*-*-* } { }
126 default {
127 run_dump_test "groupautob"
128 }
129 }
5ca0ee01
JB
130 case $target_triplet in {
131 { alpha*-*-* } { }
f42fb574
AM
132 { cr16*-*-* } { }
133 { crx*-*-* } { }
134 { h8300-*-* } { }
5ca0ee01
JB
135 { hppa*-*-* } { }
136 { iq2000*-*-* } { }
137 { mips*-*-* } { }
f42fb574
AM
138 { mn10200-*-* } { }
139 { mn10300-*-* } { }
13761a11 140 { msp43*-*-* } { }
5ca0ee01 141 { *c54x*-*-* } { }
c7927a3c 142 { rx-*-* } { }
5ca0ee01 143 default {
7b5030c0
NC
144 # The next test can fail if the target does not convert fixups
145 # against ordinary symbols into relocations against section symbols.
146 # This is usually revealed by the error message:
147 # symbol `sym' required but not present
6927f982 148 setup_xfail "m681*-*-*" "m68hc*-*-*"
5ca0ee01 149 run_dump_test redef
bdf128d6 150 run_dump_test equ-reloc
5ca0ee01
JB
151 }
152 }
6e8bd58f 153 run_dump_test "pseudo"
01642c12
RM
154 run_dump_test "section0"
155 run_dump_test "section1"
52b010e4
NC
156 if {! [istarget "h8300-*-*"]} then {
157 # The h8300 port issues a warning message for
158 # new sections created without atrributes.
159 run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
160 }
01642c12 161 run_dump_test "section3"
22fe14ad 162 run_dump_test "section4"
a22429b9 163 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
52b010e4
NC
164 # The h8300 port issues a warning message for
165 # new sections created without atrributes.
a22429b9
NC
166 # The RX port does not complain about changing the attributes of the
167 # .data and .bss sections since it does not use those names.
52b010e4
NC
168 run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
169 }
01642c12 170 run_dump_test "struct"
79c07750
RH
171 if { ![istarget "alpha*-*-*"] } then {
172 # The alpha port uses .set for state, e.g. nomacro.
173 run_dump_test "symtab"
174 }
d8045f23
NC
175 run_dump_test "symver"
176
516e75be 177 # No indirect functions on non-GNU targets.
b6605ddd 178 # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
cec7aa6a
AM
179 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
180 # So for these targets we cannot include an IFUNC symbol type
181 # in the symbol type test.
516e75be 182 if { [istarget "*-*-hpux*"]
b6605ddd 183 || [istarget "visium-*-*"]
516e75be
AM
184 || [istarget "msp*-*-*"]
185 || [istarget "arm*-*-*"]} then {
186 # hppa64 has a non-standard common directive
187 if { ![istarget "hppa64*-*-hpux*"] } then {
017761ea 188 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
516e75be 189 }
cec7aa6a 190 } else {
516e75be
AM
191 run_dump_test ifunc-1
192 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
d8045f23
NC
193 }
194
01642c12
RM
195 run_dump_test "section6"
196 run_dump_test "section7"
197 run_dump_test "section8"
68efed41 198 run_dump_test "section9"
01642c12
RM
199 run_dump_test "dwarf2-1"
200 run_dump_test "dwarf2-2"
201 run_dump_test "dwarf2-3"
24a2d04d 202 run_dump_test "dwarf2-4"
8f3bae45 203 run_dump_test "bad-section-flag"
093a6ec6 204 run_dump_test "bad-size"
cfba7fd5 205 run_dump_test "bad-group"
9aec2026 206
7bfd842d
NC
207 run_dump_test "syms"
208
f3aa8054
L
209 run_dump_test "common1"
210 run_dump_test "common2"
211
ef10c3ac
L
212 run_dump_test "strtab"
213
9aec2026
NC
214load_lib gas-dg.exp
215dg-init
216dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
217dg-finish
218
98944905 219}