]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/testsuite/gas/elf/elf.exp
* read.c (read_symbol_name): New function. Reads a symbol names.
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / elf / elf.exp
1 #
2 # elf tests
3 #
4
5 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
6 global READELF
7 global srcdir subdir
8 set testname "elf $name list"
9 set file $srcdir/$subdir/$name
10 gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
11 if { ![string match "" $opts]
12 && [regexp_diff "dump.out" "${file}.l"] } then {
13 fail $testname
14 verbose "output is [file_contents "dump.out"]" 2
15 return
16 }
17 send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
18 set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"]
19 if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then {
20 send_log "[lindex $status 1]\n"
21 fail $testname
22 return
23 }
24 catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output
25 if ![string match "" $comp_output] then {
26 send_log "$comp_output\n"
27 fail $testname
28 return
29 }
30 verbose_eval {[file_contents "dump.out"]} 3
31 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
32 fail $testname
33 verbose "output is [file_contents "dump.out"]" 2
34 return
35 }
36 pass $testname
37 }
38
39 # We're testing bits in obj-elf -- don't run on anything else.
40 if { [is_elf_format] } then {
41 set target_machine ""
42 if {[istarget "mips*-*-*"]} then {
43 set target_machine -mips
44 }
45 if {[istarget m32r*-*-*]} then {
46 set target_machine -m32r
47 }
48 if {[istarget "score-*-*"]} then {
49 set target_machine -score
50 }
51 if {[istarget "tic6x-*-*"]} then {
52 set target_machine -tic6x
53 }
54 if {[istarget "xtensa*-*-*"]} then {
55 set target_machine -xtensa
56 }
57 if {[istarget "rx-*-*"]} then {
58 set target_machine -rx
59 }
60 if {[istarget "arm*-*-*"]} {
61
62 if { ([istarget "*-*-*eabi"]
63 || [istarget "*-*-linux-*"]
64 || [istarget "*-*-nacl*"]
65 || [istarget "*-*-symbianelf"])} then {
66 set target_machine -armeabi
67 } else {
68 set target_machine -armelf
69 }
70 }
71
72 # The MN10300 and Xtensa ports disable the assembler's call frame
73 # optimization because it interfers with link-time relaxation of
74 # function prologues.
75 if {![istarget "mn10300-*-*"]
76 && ![istarget "xtensa*-*-*"]
77 && ![istarget "am3*-*-*"]} then {
78 run_dump_test "ehopt0"
79 }
80 case $target_triplet in {
81 { m68k-*-* m68[03]??-*-* } {
82 run_dump_test "file" { { as "--defsym m68k=1" } }
83 }
84 { mmix-*-* } {
85 run_dump_test "file" { { as "--defsym mmix=1" } }
86 }
87 { xtensa*-*-* } {
88 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
89 }
90 default {
91 run_dump_test "file"
92 }
93 }
94 run_dump_test "group0a"
95 run_dump_test "group0b"
96 run_dump_test "group0c"
97 run_dump_test "group1a"
98 run_dump_test "group1b"
99 case $target_triplet in {
100 { hppa64*-*-hpux* } { }
101 default {
102 run_dump_test "groupautoa"
103 }
104 }
105 case $target_triplet in {
106 { hppa64*-*-hpux* } { }
107 { xtensa*-*-* } { }
108 default {
109 run_dump_test "groupautob"
110 }
111 }
112 case $target_triplet in {
113 { alpha*-*-* } { }
114 { cr16*-*-* } { }
115 { crx*-*-* } { }
116 { h8300-*-* } { }
117 { hppa*-*-* } { }
118 { iq2000*-*-* } { }
119 { mips*-*-* } { }
120 { mn10200-*-* } { }
121 { mn10300-*-* } { }
122 { *c54x*-*-* } { }
123 { rx-*-* } { }
124 default {
125 # The next test can fail if the target does not convert fixups
126 # against ordinary symbols into relocations against section symbols.
127 # This is usually revealed by the error message:
128 # symbol `sym' required but not present
129 setup_xfail "m681*-*-*" "m68hc*-*-*"
130 run_dump_test redef
131 run_dump_test equ-reloc
132 }
133 }
134 run_dump_test "pseudo"
135 run_dump_test "section0"
136 run_dump_test "section1"
137 if {! [istarget "h8300-*-*"]} then {
138 # The h8300 port issues a warning message for
139 # new sections created without atrributes.
140 run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
141 }
142 run_dump_test "section3"
143 run_dump_test "section4"
144 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
145 # The h8300 port issues a warning message for
146 # new sections created without atrributes.
147 # The RX port does not complain about changing the attributes of the
148 # .data and .bss sections since it does not use those names.
149 run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
150 }
151 run_dump_test "struct"
152 if { ![istarget "alpha*-*-*"] } then {
153 # The alpha port uses .set for state, e.g. nomacro.
154 run_dump_test "symtab"
155 }
156 run_dump_test "symver"
157
158 # No indirect functions on non-GNU targets.
159 # The MSP port sets the ELF header's OSABI field to ELFOSABI_STANDALONE.
160 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
161 # So for these targets we cannot include an IFUNC symbol type
162 # in the symbol type test.
163 if { [istarget "*-*-hpux*"]
164 || [istarget "msp*-*-*"]
165 || [istarget "arm*-*-*"]} then {
166 # hppa64 has a non-standard common directive
167 if { ![istarget "hppa64*-*-hpux*"] } then {
168 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
169 }
170 } else {
171 run_dump_test ifunc-1
172 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
173 }
174
175 run_dump_test "section6"
176 run_dump_test "section7"
177 run_dump_test "section8"
178 run_dump_test "section9"
179 run_dump_test "dwarf2-1"
180 run_dump_test "dwarf2-2"
181 run_dump_test "dwarf2-3"
182 run_dump_test "dwarf2-4"
183 run_dump_test "bad-section-flag"
184 run_dump_test "bad-size"
185 run_dump_test "bad-group"
186
187 run_dump_test "syms"
188
189 load_lib gas-dg.exp
190 dg-init
191 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
192 dg-finish
193
194 }