2000-10-31 Philip Blundell <philb@gnu.org>
[binutils.git] / ld / testsuite / ld-scripts / script.exp
blob94c5d9b7a39fc97bb5981df18e3f666bf22654af
1 # Test basic linker script functionality
2 # By Ian Lance Taylor, Cygnus Support
4 set testname "script"
6 if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] {
7 unresolved $testname
8 return
11 proc check_script { } {
12 global nm
13 global testname
14 global nm_output
16 if ![ld_nm $nm tmpdir/script] {
17 unresolved $testname
18 } else {
19 if {![info exists nm_output(text_start)] \
20 || ![info exists nm_output(text_end)] \
21 || ![info exists nm_output(data_start)] \
22 || ![info exists nm_output(data_end)]} {
23 send_log "bad output from nm\n"
24 verbose "bad output from nm"
25 fail $testname
26 } else {
27 set text_end 0x104
28 set data_end 0x1004
29 if [istarget *c54x*-*-*] then {
30 set text_end 0x102
31 set data_end 0x1002
33 if {$nm_output(text_start) != 0x100} {
34 send_log "text_start == $nm_output(text_start)\n"
35 verbose "text_start == $nm_output(text_start)"
36 fail $testname
37 } else { if {$nm_output(text_end) < $text_end \
38 || $nm_output(text_end) > 0x110} {
39 send_log "text_end == $nm_output(text_end)\n"
40 verbose "text_end == $nm_output(text_end)"
41 fail $testname
42 } else { if {$nm_output(data_start) != 0x1000} {
43 send_log "data_start == $nm_output(data_start)\n"
44 verbose "data_start == $nm_output(data_start)"
45 fail $testname
46 } else { if {$nm_output(data_end) < $data_end \
47 || $nm_output(data_end) > 0x1010} {
48 send_log "data_end == $nm_output(data_end)\n"
49 verbose "data_end == $nm_output(data_end)"
50 fail $testname
51 } else {
52 pass $testname
53 } } } }
58 # PE targets need to set the image base to 0 to avoid complications from nm.
59 set flags ""
60 if {[istarget "*-*-pe*"] \
61 || [istarget "*-*-cygwin*"] \
62 || [istarget "*-*-mingw32*"] \
63 || [istarget "*-*-winnt*"] \
64 || [istarget "*-*-nt*"] \
65 || [istarget "*-*-interix*"] } then {
66 set flags "--image-base 0"
69 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
70 fail $testname
71 } else {
72 check_script
75 set testname "MRI script"
77 if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
78 fail $testname
79 } else {
80 check_script