fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / binutils / ld / testsuite / ld-elfcomm / elfcomm.exp
blobe5bd29b62f5d3e1c76d586d6a0ba0fb0da3cfa21
1 # Expect script for common symbol tests
2 # Copyright 2003 Free Software Foundation, Inc.
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.
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.
18 # Written by H.J. Lu (hjl@gnu.org)
21 # Make sure that ld correctly handles common symbols in ELF.
23 # This test can only be run on ELF platforms.
24 if ![is_elf_format] {
25 return
28 set test1 "size/aligment change of common symbols"
29 set test1w1 "$test1 (warning 1)"
30 set test1w2 "$test1 (warning 2)"
31 set test1c1 "$test1 (change 1)"
32 set test1c2 "$test1 (change 2)"
34 if { [which $CC] == 0 } {
35 untested $test1w1
36 untested $test1w2
37 untested $test1c1
38 untested $test1c2
39 return
42 proc dump_common1 { testname } {
43 global exec_output
44 global READELF
46 send_log "$READELF -s tmpdir/common1.o | grep foo\n"
47 catch "exec $READELF -s tmpdir/common1.o | grep foo" exec_output
48 if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+)4(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)COM(\[ \]+)_?foo2" $exec_output]
49 || ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)21(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo1" $exec_output] } {
50 send_log "$exec_output\n"
51 verbose $exec_output
52 fail $testname
53 return 0
56 return 1
59 if { ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
60 || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o] } {
61 unresolved $test1
62 return
65 global ld
66 global link_output
68 if { [ld_simple_link $ld tmpdir/common1.o "-r tmpdir/common1a.o tmpdir/common1b.o"] } {
69 unresolved $test1w1
70 return
73 if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output]
74 || ![regexp "Warning: size of symbol \`_?foo1\' changed from 2 in tmpdir/common1a.o to 21 in tmpdir/common1b.o" $link_output] } {
75 fail $test1w1
76 } else {
77 pass $test1w1
80 if { [dump_common1 $test1c1] } {
81 pass $test1c1
84 if { [ld_simple_link $ld tmpdir/common1.o "-r tmpdir/common1b.o tmpdir/common1a.o"] } {
85 unresolved $test1w2
86 return
89 if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] } {
90 fail $test1w2
91 } else {
92 pass $test1w2
95 if { [dump_common1 $test1c2] } {
96 pass $test1c2