Home | History | Annotate | Download | only in ld-scripts
      1 # Test SIZEOF in a linker script.
      2 # By Ian Lance Taylor, Cygnus Support
      3 # Based on a bug report from anders.blomdell (at) control.lth.se.
      4 #   Copyright (C) 2001-2014 Free Software Foundation, Inc.
      5 #
      6 # This file is part of the GNU Binutils.
      7 #
      8 # This program is free software; you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation; either version 3 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This program is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this program; if not, write to the Free Software
     20 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     21 # MA 02110-1301, USA.
     22 
     23 set testname "SIZEOF"
     24 
     25 if ![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/sizeof.o] {
     26     unresolved $testname
     27     return
     28 }
     29 
     30 if ![ld_simple_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] {
     31     fail $testname
     32     return
     33 }
     34 
     35 if ![ld_nm $nm "" tmpdir/sizeof] {
     36     unresolved $testname
     37     return
     38 }
     39 
     40 if {![info exists nm_output(text_start)] \
     41      || ![info exists nm_output(text_end)] \
     42      || ![info exists nm_output(data_start)] \
     43      || ![info exists nm_output(data_end)] \
     44      || ![info exists nm_output(sizeof_text)] \
     45      || ![info exists nm_output(sizeof_data)]} {
     46     send_log "bad output from nm\n"
     47     verbose "bad output from nm"
     48     fail $testname
     49     return
     50 }
     51 
     52 if {$nm_output(text_end) - $nm_output(text_start) != $nm_output(sizeof_text)} {
     53     send_log "text_end - text_start != sizeof_text\n"
     54     verbose "text_end - text_start != sizeof_text"
     55     fail $testname
     56     return
     57 }
     58 
     59 if {$nm_output(data_end) - $nm_output(data_start) != $nm_output(sizeof_data)} {
     60     send_log "data_end - data_start != sizeof_data\n"
     61     verbose "data_end - data_start != sizeof_data"
     62     fail $testname
     63     return
     64 }
     65 
     66 if {$nm_output(sizeof_text) != $nm_output(sizeof_data)} {
     67     send_log "sizeof_text != sizeof_data\n"
     68     verbose "sizeof_text != sizeof_data"
     69     fail $testname
     70     return
     71 }
     72 
     73 pass $testname
     74