6c90c2b914209525835d8a115d2ba53b9cbb5332
[deliverable/binutils-gdb.git] / ld / testsuite / ld-xtensa / lcall.exp
1 # Test Xtensa longcall optimization.
2 # By David Heine, Tensilica, Inc.
3 # Copyright (C) 2002-2016 Free Software Foundation, Inc.
4 #
5 # This file is part of the GNU Binutils.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 # MA 02110-1301, USA.
21
22 if ![istarget "xtensa*-*-*"] {
23 return
24 }
25
26 set testname "LCALL"
27
28 set OBJDUMPFLAGS "-dr"
29
30 #
31 # default_ld_objdump
32 # run objdump on a file
33 #
34 proc default_ld_objdump { objdump object outputfile } {
35 global OBJDUMPFLAGS
36 global objdump_output
37 global host_triplet
38
39 if {[which $objdump] == 0} then {
40 perror "$objdump does not exist"
41 return 0
42 }
43
44 if ![info exists OBJDUMPFLAGS] { set OBJDUMPFLAGS "" }
45
46 verbose -log "$objdump $OBJDUMPFLAGS $object >$outputfile"
47
48 catch "exec $objdump $OBJDUMPFLAGS $object >$outputfile" exec_output
49 set exec_output [prune_warnings $exec_output]
50 if [string match "" $exec_output] then {
51 return 1
52 } else {
53 verbose -log "$exec_output"
54 perror "$object: objdump failed"
55 return 0
56 }
57 }
58
59
60 if ![ld_assemble $as $srcdir/$subdir/lcall1.s tmpdir/lcall1.o] {
61 unresolved $testname
62 return
63 }
64 if ![ld_assemble $as $srcdir/$subdir/lcall2.s tmpdir/lcall2.o] {
65 unresolved $testname
66 return
67 }
68
69 set object "tmpdir/lcall"
70 set outputfile "$object.txt"
71
72 if ![ld_simple_link $ld $object "-T $srcdir/$subdir/lcall.t tmpdir/lcall1.o tmpdir/lcall2.o"] {
73 verbose -log "failure in ld"
74 fail $testname
75 return
76 }
77
78 if ![default_ld_objdump $objdump $object $outputfile ] {
79 verbose -log "failure in objdump"
80 fail $testname
81 return
82 }
83
84 set file [open $outputfile r]
85 while { [gets $file line] != -1 } {
86 # verbose "$line" 2
87 if [regexp "l32r" $line] {
88 verbose -log "Found an l32r in the linked object"
89 verbose -log "$line"
90 fail $testname
91 }
92 }
93 close $file
94 pass $testname
95
96
97 set testname "LCALL2"
98 set file [open $outputfile r]
99 set found 0
100
101 while { [gets $file line] != -1 } {
102 # verbose "$line" 2
103 if [regexp "^00000004 <label1>:" $line] {
104 set found 1
105 }
106 }
107 close $file
108 if $found {
109 pass $testname
110 } else {
111 fail $testname
112 }
113
This page took 0.031527 seconds and 3 git commands to generate.