]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-scripts/sizeof.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-scripts / sizeof.exp
CommitLineData
252b5132
RH
1# Test SIZEOF in a linker script.
2# By Ian Lance Taylor, Cygnus Support
3# Based on a bug report from anders.blomdell@control.lth.se.
a2c58332 4# Copyright (C) 2001-2022 Free Software Foundation, Inc.
a2b64bed 5#
f96b4a7b
NC
6# This file is part of the GNU Binutils.
7#
8# This program is free software; you can redistribute it and/or modify
a2b64bed 9# it under the terms of the GNU General Public License as published by
f96b4a7b 10# the Free Software Foundation; either version 3 of the License, or
a2b64bed 11# (at your option) any later version.
f96b4a7b 12#
a2b64bed
NC
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.
f96b4a7b 17#
a2b64bed
NC
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
f96b4a7b
NC
20# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21# MA 02110-1301, USA.
252b5132
RH
22
23set testname "SIZEOF"
24
25if ![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/sizeof.o] {
5b1f6c95 26 unsupported $testname
252b5132
RH
27 return
28}
29
87fa7d56
JB
30if { [is_pecoff_format] } {
31 set IMAGE_BASE "--image-base 0"
32} else {
33 set IMAGE_BASE ""
34}
35
36if ![ld_link $ld tmpdir/sizeof "$LDFLAGS -T $srcdir/$subdir/sizeof.t \
37 $IMAGE_BASE tmpdir/sizeof.o"] {
252b5132
RH
38 fail $testname
39 return
40}
41
992c450d 42if ![ld_nm $nm "" tmpdir/sizeof] {
348fe36b 43 fail $testname
252b5132
RH
44 return
45}
46
47if {![info exists nm_output(text_start)] \
48 || ![info exists nm_output(text_end)] \
49 || ![info exists nm_output(data_start)] \
50 || ![info exists nm_output(data_end)] \
51 || ![info exists nm_output(sizeof_text)] \
52 || ![info exists nm_output(sizeof_data)]} {
53 send_log "bad output from nm\n"
54 verbose "bad output from nm"
55 fail $testname
56 return
57}
58
59if {$nm_output(text_end) - $nm_output(text_start) != $nm_output(sizeof_text)} {
60 send_log "text_end - text_start != sizeof_text\n"
61 verbose "text_end - text_start != sizeof_text"
62 fail $testname
63 return
64}
65
66if {$nm_output(data_end) - $nm_output(data_start) != $nm_output(sizeof_data)} {
67 send_log "data_end - data_start != sizeof_data\n"
68 verbose "data_end - data_start != sizeof_data"
69 fail $testname
70 return
71}
72
73if {$nm_output(sizeof_text) != $nm_output(sizeof_data)} {
74 send_log "sizeof_text != sizeof_data\n"
75 verbose "sizeof_text != sizeof_data"
76 fail $testname
77 return
78}
79
80pass $testname