Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # Test basic linker script functionality |
2 | # By Ian Lance Taylor, Cygnus Support | |
a2b64bed NC |
3 | # Copyright 2001 |
4 | # Free Software Foundation, Inc. | |
5 | # | |
6 | # This file is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 2 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program; if not, write to the Free Software | |
18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
252b5132 RH |
19 | |
20 | set testname "script" | |
21 | ||
22 | if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] { | |
23 | unresolved $testname | |
24 | return | |
25 | } | |
26 | ||
27 | proc check_script { } { | |
28 | global nm | |
29 | global testname | |
30 | global nm_output | |
31 | ||
992c450d | 32 | if ![ld_nm $nm "" tmpdir/script] { |
252b5132 RH |
33 | unresolved $testname |
34 | } else { | |
35 | if {![info exists nm_output(text_start)] \ | |
36 | || ![info exists nm_output(text_end)] \ | |
37 | || ![info exists nm_output(data_start)] \ | |
38 | || ![info exists nm_output(data_end)]} { | |
39 | send_log "bad output from nm\n" | |
40 | verbose "bad output from nm" | |
41 | fail $testname | |
42 | } else { | |
74459f0e TW |
43 | set text_end 0x104 |
44 | set data_end 0x1004 | |
48c5eb8a SS |
45 | if [istarget *c4x*-*-*] then { |
46 | set text_end 0x101 | |
47 | set data_end 0x1001 | |
48 | } | |
74459f0e TW |
49 | if [istarget *c54x*-*-*] then { |
50 | set text_end 0x102 | |
51 | set data_end 0x1002 | |
52 | } | |
252b5132 RH |
53 | if {$nm_output(text_start) != 0x100} { |
54 | send_log "text_start == $nm_output(text_start)\n" | |
55 | verbose "text_start == $nm_output(text_start)" | |
56 | fail $testname | |
74459f0e | 57 | } else { if {$nm_output(text_end) < $text_end \ |
252b5132 RH |
58 | || $nm_output(text_end) > 0x110} { |
59 | send_log "text_end == $nm_output(text_end)\n" | |
60 | verbose "text_end == $nm_output(text_end)" | |
61 | fail $testname | |
62 | } else { if {$nm_output(data_start) != 0x1000} { | |
63 | send_log "data_start == $nm_output(data_start)\n" | |
64 | verbose "data_start == $nm_output(data_start)" | |
65 | fail $testname | |
74459f0e | 66 | } else { if {$nm_output(data_end) < $data_end \ |
252b5132 RH |
67 | || $nm_output(data_end) > 0x1010} { |
68 | send_log "data_end == $nm_output(data_end)\n" | |
69 | verbose "data_end == $nm_output(data_end)" | |
70 | fail $testname | |
71 | } else { | |
72 | pass $testname | |
73 | } } } } | |
74 | } | |
75 | } | |
76 | } | |
77 | ||
777690b6 ILT |
78 | # PE targets need to set the image base to 0 to avoid complications from nm. |
79 | set flags "" | |
80 | if {[istarget "*-*-pe*"] \ | |
81 | || [istarget "*-*-cygwin*"] \ | |
82 | || [istarget "*-*-mingw32*"] \ | |
83 | || [istarget "*-*-winnt*"] \ | |
84 | || [istarget "*-*-nt*"] \ | |
85 | || [istarget "*-*-interix*"] } then { | |
86 | set flags "--image-base 0" | |
87 | } | |
88 | ||
89 | if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] { | |
252b5132 RH |
90 | fail $testname |
91 | } else { | |
92 | check_script | |
93 | } | |
94 | ||
95 | set testname "MRI script" | |
96 | ||
777690b6 | 97 | if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] { |
252b5132 RH |
98 | fail $testname |
99 | } else { | |
100 | check_script | |
101 | } |