1 # Test basic linker script functionality
2 # By Ian Lance Taylor, Cygnus Support
3 # Copyright (C) 1999-2015 Free Software Foundation, Inc.
5 # This file is part of the GNU Binutils.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24 if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] {
29 proc check_script { } {
34 if ![ld_nm $nm "" tmpdir/script] {
39 if {![info exists nm_output(text_start)] \
40 || ![info exists nm_output(text_end)] \
41 || ![info exists nm_output(data_start)] \
42 || ![info exists nm_output(data_end)]} {
43 send_log "bad output from nm\n"
44 verbose "bad output from nm"
53 if [istarget *c4x*-*-*] then {
58 if [istarget *c54x*-*-*] then {
63 if {$nm_output(text_start) != 0x100} {
64 send_log "text_start == $nm_output(text_start)\n"
65 verbose "text_start == $nm_output(text_start)"
69 if {[info exists nm_output(tred)] \
70 && $nm_output(tred) != (0x100 + 0x8000)} {
71 send_log "tred == $nm_output(tred)\n"
72 verbose "tred == $nm_output(tred)"
76 if {$nm_output(text_end) < $text_end \
77 || $nm_output(text_end) > 0x110} {
78 send_log "text_end == $nm_output(text_end)\n"
79 verbose "text_end == $nm_output(text_end)"
83 if {$nm_output(data_start) != 0x1000} {
84 send_log "data_start == $nm_output(data_start)\n"
85 verbose "data_start == $nm_output(data_start)"
89 if {[info exists nm_output(fred)] \
90 && $nm_output(fred) != (0x1000 + 0x10000)} {
91 send_log "fred == $nm_output(fred)\n"
92 verbose "fred == $nm_output(fred)"
96 if {$nm_output(data_end) < $data_end \
97 || $nm_output(data_end) > 0x1010} {
98 send_log "data_end == $nm_output(data_end)\n"
99 verbose "data_end == $nm_output(data_end)"
110 # PE targets need to set the image base to 0 to avoid complications from nm.
112 if {[istarget "*-*-pe*"] \
113 || [istarget "*-*-cygwin*"] \
114 || [istarget "*-*-mingw*"] \
115 || [istarget "*-*-winnt*"] \
116 || [istarget "*-*-nt"] \
117 || [istarget "*-*-interix*"] } then {
118 set flags "--image-base 0"
121 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
127 set testname "MRI script"
129 if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
135 set testname "MEMORY"
137 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
143 set testname "MEMORY with symbols"
144 if ![ld_simple_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
150 set test_script_list [lsort [glob $srcdir/$subdir/region-alias-*.t]]
152 foreach test_script $test_script_list {
153 run_dump_test [string range $test_script 0 end-2]
156 run_dump_test "align-with-input"