* ld-elf/elf.exp: Use if_elf_format.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elfcomm / elfcomm.exp
CommitLineData
09bf9720 1# Expect script for common symbol tests
ca4fa240
NC
2# Copyright 2003 Free Software Foundation, Inc.
3#
4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17#
18# Written by H.J. Lu (hjl@gnu.org)
19#
20
21# Make sure that ld correctly handles common symbols in ELF.
22
23# This test can only be run on ELF platforms.
43f9d75b 24if ![is_elf_format] {
ca4fa240
NC
25 return
26}
27
28proc dump_common1 { testname } {
29 global exec_output
30
31 send_log "readelf -s tmpdir/common1.o | grep foo\n"
32 catch "exec readelf -s tmpdir/common1.o | grep foo" exec_output
09bf9720
L
33 if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+)4(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)COM(\[ \]+)_?foo2" $exec_output]
34 || ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)21(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo1" $exec_output] } {
ca4fa240
NC
35 send_log "$exec_output\n"
36 verbose $exec_output
37 fail $testname
38 return 0
39 }
40
41 return 1
42}
43
09bf9720 44set test1 "size/aligment change of common symbols"
ca4fa240
NC
45if { ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
46 || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o] } {
47 unresolved $test1
48 return
49}
50
51global ld
52global link_output
53
54if { [ld_simple_link $ld tmpdir/common1.o "-r tmpdir/common1a.o tmpdir/common1b.o"] } {
37adfc7e 55 unresolved "$test1 (warning 1)"
ca4fa240
NC
56 return
57}
58
09bf9720
L
59if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output]
60 || ![regexp "Warning: size of symbol \`_?foo1\' changed from 2 in tmpdir/common1a.o to 21 in tmpdir/common1b.o" $link_output] } {
ca4fa240
NC
61 fail "$test1 (warning 1)"
62} else {
63 pass "$test1 (warning 1)"
64}
65
66if { [dump_common1 "$test1 (change 1)"] } {
67 pass "$test1 (change 1)"
68}
69
70if { [ld_simple_link $ld tmpdir/common1.o "-r tmpdir/common1b.o tmpdir/common1a.o"] } {
37adfc7e 71 unresolved "$test1 (warning 2)"
ca4fa240
NC
72 return
73}
74
09bf9720 75if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] } {
ca4fa240
NC
76 fail "$test1 (warning 2)"
77} else {
37adfc7e 78 pass "$test1 (warning 2)"
ca4fa240
NC
79}
80
81if { [dump_common1 "$test1 (change 2)"] } {
82 pass "$test1 (change 2)"
83}
This page took 0.031948 seconds and 4 git commands to generate.