Mention Coverity's contribution to bfd
[deliverable/binutils-gdb.git] / ld / testsuite / ld-scripts / crossref.exp
... / ...
CommitLineData
1# Test NOCROSSREFS in a linker script.
2# By Ian Lance Taylor, Cygnus Support.
3# Copyright 2000, 2001, 2002, 2003, 2004, 2007
4# 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
23set test1 "NOCROSSREFS 1"
24set test2 "NOCROSSREFS 2"
25set test3 "NOCROSSREFS 3"
26
27if { [which $CC] == 0 } {
28 untested $test1
29 untested $test2
30 untested $test3
31 return
32}
33
34# Xtensa targets currently default to putting literal values in a separate
35# section and that requires linker script support, so put literals in text.
36global CFLAGS
37if [istarget xtensa*-*-*] {
38 set CFLAGS "$CFLAGS -mtext-section-literals"
39}
40
41# If we have a compiler that doesn't use/reference dot-symbols, then
42# calls to functions reference the .opd section function descriptor.
43# This makes NOCROSSREFS rather useless on powerpc64.
44if [istarget powerpc64*-*-*] {
45 set CFLAGS "$CFLAGS -mcall-aixdesc"
46}
47
48if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
49 || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
50 unresolved $test1
51 unresolved $test2
52 return
53}
54
55set flags [big_or_little_endian]
56
57if [istarget sh64*-*-elf] {
58 # This is what gcc passes to ld by default.
59 set flags "-mshelf32"
60}
61
62# IA64 has both ordered and unordered sections in an input file.
63setup_xfail ia64-*-*
64
65verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
66
67catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
68
69set exec_output [prune_warnings $exec_output]
70
71regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
72
73if [string match "" $exec_output] then {
74 fail $test1
75} else {
76 verbose -log "$exec_output"
77 if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] {
78 pass $test1
79 } else {
80 fail $test1
81 }
82}
83
84# Check cross references within a single object.
85
86if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
87 unresolved $test2
88 return
89}
90
91verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
92
93catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
94
95set exec_output [prune_warnings $exec_output]
96
97regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
98
99if [string match "" $exec_output] then {
100 fail $test2
101} else {
102 verbose -log "$exec_output"
103 if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
104 pass $test2
105 } else {
106 fail $test2
107 }
108}
109
110# Check cross references for ld -r
111
112if { ![ld_compile $CC "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
113 unresolved $test3
114 return
115}
116
117if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
118 unresolved $test3
119 return
120}
121
122verbose -log "$ld $flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o"
123
124catch "exec $ld $flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o" exec_output
125
126set exec_output [prune_warnings $exec_output]
127
128regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
129
130if [string match "" $exec_output] then {
131 pass $test3
132} else {
133 verbose -log "$exec_output"
134 fail $test3
135}
This page took 0.023035 seconds and 4 git commands to generate.