Commit | Line | Data |
---|---|---|
09bf9720 | 1 | # Expect script for common symbol tests |
1c0d3aa6 | 2 | # Copyright 2003, 2005, 2006 Free Software Foundation, Inc. |
ca4fa240 NC |
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 | |
75be928b | 16 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
ca4fa240 NC |
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 | 24 | if ![is_elf_format] { |
ca4fa240 NC |
25 | return |
26 | } | |
27 | ||
b814bbcb L |
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)" | |
33 | ||
34 | if { [which $CC] == 0 } { | |
35 | untested $test1w1 | |
36 | untested $test1w2 | |
37 | untested $test1c1 | |
38 | untested $test1c2 | |
39 | return | |
40 | } | |
1c0d3aa6 NC |
41 | if { [istarget score-*-*] } { |
42 | untested $test1w1 | |
43 | untested $test1w2 | |
44 | untested $test1c1 | |
45 | untested $test1c2 | |
46 | return | |
47 | } | |
b814bbcb | 48 | |
ca4fa240 NC |
49 | proc dump_common1 { testname } { |
50 | global exec_output | |
a42ec05b | 51 | global READELF |
ca4fa240 | 52 | |
a42ec05b HPN |
53 | send_log "$READELF -s tmpdir/common1.o | grep foo\n" |
54 | catch "exec $READELF -s tmpdir/common1.o | grep foo" exec_output | |
f46cb541 | 55 | if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+)4(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(PRC\\\[0xff03\\\]|COM|SCOM)(\[ \]+)_?foo2" $exec_output] |
09bf9720 | 56 | || ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)21(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo1" $exec_output] } { |
ca4fa240 NC |
57 | send_log "$exec_output\n" |
58 | verbose $exec_output | |
59 | fail $testname | |
60 | return 0 | |
61 | } | |
62 | ||
63 | return 1 | |
64 | } | |
65 | ||
ca4fa240 NC |
66 | if { ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o] |
67 | || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o] } { | |
68 | unresolved $test1 | |
69 | return | |
70 | } | |
71 | ||
72 | global ld | |
73 | global link_output | |
74 | ||
75 | if { [ld_simple_link $ld tmpdir/common1.o "-r tmpdir/common1a.o tmpdir/common1b.o"] } { | |
b814bbcb | 76 | unresolved $test1w1 |
ca4fa240 NC |
77 | return |
78 | } | |
79 | ||
674e82fc TS |
80 | # This test fails on MIPS because the backend sets type_change_ok. |
81 | # The size change warning is suppressed. | |
82 | if {[istarget mips*-*-*]} { | |
83 | if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] } { | |
84 | fail $test1w1 | |
a5e0d269 | 85 | } else { |
674e82fc | 86 | pass $test1w1 |
a5e0d269 | 87 | } |
ca4fa240 | 88 | } else { |
b814bbcb | 89 | pass $test1w1 |
674e82fc TS |
90 | if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] |
91 | || ![regexp "Warning: size of symbol \`_?foo1\' changed from 2 in tmpdir/common1a.o to 21 in tmpdir/common1b.o" $link_output] } { | |
92 | fail $test1w1 | |
93 | } else { | |
94 | pass $test1w1 | |
95 | } | |
ca4fa240 NC |
96 | } |
97 | ||
b814bbcb L |
98 | if { [dump_common1 $test1c1] } { |
99 | pass $test1c1 | |
ca4fa240 NC |
100 | } |
101 | ||
102 | if { [ld_simple_link $ld tmpdir/common1.o "-r tmpdir/common1b.o tmpdir/common1a.o"] } { | |
b814bbcb | 103 | unresolved $test1w2 |
ca4fa240 NC |
104 | return |
105 | } | |
106 | ||
09bf9720 | 107 | if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] } { |
b814bbcb | 108 | fail $test1w2 |
ca4fa240 | 109 | } else { |
b814bbcb | 110 | pass $test1w2 |
ca4fa240 NC |
111 | } |
112 | ||
b814bbcb L |
113 | if { [dump_common1 $test1c2] } { |
114 | pass $test1c2 | |
ca4fa240 | 115 | } |