Home | History | Annotate | Download | only in ld-xtensa
      1 # Test literal coaslescing for Xtensa targets.
      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 "COALESCE"
     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/coalesce1.s tmpdir/coalesce1.o] {
     61     unresolved $testname
     62     return
     63 }
     64 if ![ld_assemble $as $srcdir/$subdir/coalesce2.s tmpdir/coalesce2.o] {
     65     unresolved $testname
     66     return
     67 }
     68 
     69 set object "tmpdir/coalesce"
     70 set outputfile "$object.txt"
     71 
     72 if ![ld_simple_link $ld $object "-T $srcdir/$subdir/coalesce.t tmpdir/coalesce1.o tmpdir/coalesce2.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 set found 0
     86 
     87 while { [gets $file line] != -1 } {
     88     #	verbose "$line" 2
     89     if [regexp "^0000000c <main>:" $line] {
     90 	set found 1
     91     }
     92 }
     93 close $file
     94 if  $found  {
     95    pass $testname
     96 } else {
     97    fail $testname
     98 }
     99 
    100