PR gas/4804
[external/binutils.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     catch "exec $READELF $readelf_opts dump.o $readelf_pipe > dump.out\n" comp_output
19     if ![string match "" $comp_output] then {
20         send_log "$comp_output\n"
21         fail $testname
22         return
23     }
24     verbose_eval {[file_contents "dump.out"]} 3
25     if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
26         fail $testname
27         verbose "output is [file_contents "dump.out"]" 2
28         return
29     }
30     pass $testname
31 }
32
33 # We're testing bits in obj-elf -- don't run on anything else.
34 if { ([istarget "*-*-*elf*"]            
35       || [istarget "*-*-linux*"]
36       || [istarget "m6811-*"]
37       || [istarget "m6812-*"]
38       || [istarget "sparc*-*-solaris*"]
39       || [istarget "mips*-*-irix6*"]
40       || [istarget "arm*-*-eabi"])
41      && ![istarget *-*-linux*aout*]
42      && ![istarget *-*-linux*coff*]
43      && ![istarget *-*-linux*oldld*]
44      && ![istarget sh64*-*-linux*]
45 } then {
46     set target_machine ""
47     if {[istarget "mips*-*-*"]} then {
48         set target_machine -mips
49     }
50     if {[istarget m32r*-*-*]} then {
51         set target_machine -m32r
52     }
53     if {[istarget "score-*-*"]} then {
54         set target_machine -score
55     }
56     if {[istarget "xtensa-*-*"]} then {
57         set target_machine -xtensa
58     }
59     if { ([istarget "*arm*-*-*"]
60           || [istarget "xscale*-*-*"]) } {
61         
62         if { ([istarget "*-*-*eabi"]
63               || [istarget "*-*-linux-*"]
64               || [istarget "*-*-symbianelf"])} then {
65             set target_machine -armeabi
66         } else {
67             set target_machine -armelf
68         }
69     }
70     run_dump_test "ehopt0"
71     run_dump_test "group0a" 
72     run_dump_test "group0b" 
73     run_dump_test "group1a" 
74     run_dump_test "group1b" 
75     case $target_triplet in {
76         { alpha*-*-* } { }
77         { hppa*-*-* } { }
78         { iq2000*-*-* } { }
79         { mips*-*-* } { }
80         { *c54x*-*-* } { }
81         default {
82             # The next test can fail if the target does not convert fixups
83             # against ordinary symbols into relocations against section symbols.
84             # This is usually revealed by the error message:
85             #  symbol `sym' required but not present
86             setup_xfail "cr16-*-*" "h8300-*-*" "mn10300-*-*"
87             run_dump_test redef
88             run_dump_test equ-reloc
89         }
90     }
91     run_dump_test "section0" 
92     run_dump_test "section1" 
93     run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
94     run_dump_test "section3" 
95     run_dump_test "section4"
96     run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
97     run_dump_test "struct" 
98     run_dump_test "symver" 
99     run_elf_list_test "type" "" "" "-s" "| grep \"1 \\\[FONT\\\]\""
100 }