1 # Expect script
for various MSP430 ELF tests.
2 # Copyright
(C
) 2002-2022 Free Software Foundation
, Inc.
4 # This file is part of the GNU Binutils.
6 # This
program 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
3 of the License
, or
9 #
(at your option
) any later version.
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.
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.
, 51 Franklin Street
- Fifth Floor
, Boston
,
22 if { ![istarget
"msp430*elf*"] } {
26 # List contains test
-items with
3 items followed by
2 lists
, one item and
29 #
1:ld/ar leading options
, placed before object files
30 #
2:ld/ar trailing options
, placed after object files
32 #
4:filenames of assembler files
33 #
5:list of actions
, options and expected outputs.
34 #
6:name of output file
35 #
7:compiler flags
(optional
)
37 # Actions
: { command command
-line
-options file
-containg
-expected
-output
-regexps
}
39 # objdump
: Apply objdump options
on result.
40 # nm
: Apply nm options
on result.
41 # readelf
: Apply readelf options
on result.
42 #
ld: Don
't apply anything on result. Compare output during linking with
43 # the file containing regexps (which is the second arg, not the third).
44 # Note that this *must* be the first action if it is to be used at all;
45 # in all other cases, any output from the linker during linking is
46 # treated as a sign of an error and FAILs the test.
50 set msp430regionprefixtests {
51 {"Move main() to .upper.text" "-T msp430.ld --code-region=upper"
52 "" "" {main-with-text-rodata.s} {{objdump -d main-text-upper.d}} "main-upper"}
53 {"Move main() to .upper.text. No .lower.text in ld script" "-T msp430-no-lower.ld --code-region=upper"
54 "" "" {main-with-text-rodata.s} {{objdump -d main-text-upper.d}} "main-upper"}
55 {"Move main() to .lower.text" "-T msp430.ld --code-region=lower"
56 "" "" {main-with-text-rodata.s} {{objdump -d main-text-lower.d}} "main-lower"}
57 {"Move \"either\" main() to .lower.text" "-T msp430.ld --code-region=either"
58 "" "" {main-with-text-rodata.s} {{objdump -d main-text-lower.d}} "main-either"}
60 {"Move glob_var to .upper.data" "-T msp430.ld --data-region=upper"
61 "" "" {main-with-data-bss.s} {{objdump -D main-var-upper.d}} "main-var-upper"}
62 {"Move glob_var to .upper.data. No .lower.data in ld script" "-T msp430-no-lower.ld --data-region=upper"
63 "" "" {main-with-data-bss.s} {{objdump -D main-var-upper.d}} "main-var-upper"}
64 {"Move glob_var to .lower.data" "-T msp430.ld --data-region=lower"
65 "" "" {main-with-data-bss.s} {{objdump -D main-var-lower.d}} "main-var-lower"}
66 {"Move \"either\" glob_var to .lower.data" "-T msp430.ld --data-region=lower"
67 "" "" {main-with-data-bss.s} {{objdump -D main-var-lower.d}} "main-var-lower"}
69 {"Move glob_zero to .upper.bss" "-T msp430.ld --data-region=upper"
70 "" "" {main-with-data-bss.s} {{objdump -D main-bss-upper.d}} "main-bss-upper"}
71 {"Move glob_zero to .upper.bss. No .lower.bss in ld script." "-T msp430-no-lower.ld --data-region=upper"
72 "" "" {main-with-data-bss.s} {{objdump -D main-bss-upper.d}} "main-bss-upper"}
73 {"Move glob_zero to .lower.bss" "-T msp430.ld --data-region=lower"
74 "" "" {main-with-data-bss.s} {{objdump -D main-bss-lower.d}} "main-bss-lower"}
75 {"Move \"either\" glob_zero to .lower.bss" "-T msp430.ld --data-region=lower"
76 "" "" {main-with-data-bss.s} {{objdump -D main-bss-lower.d}} "main-bss-lower"}
78 {"Move glob_const to .upper.rodata" "-T msp430.ld --data-region=upper"
79 "" "" {main-with-text-rodata.s} {{objdump -D main-const-upper.d}} "main-const-upper"}
80 {"Move glob_const to .upper.rodata. No .lower.rodata in ld script." "-T msp430-no-lower.ld --data-region=upper"
81 "" "" {main-with-text-rodata.s} {{objdump -D main-const-upper.d}} "main-const-upper"}
82 {"Move glob_const to .lower.rodata" "-T msp430.ld --data-region=lower"
83 "" "" {main-with-text-rodata.s} {{objdump -D main-const-lower.d}} "main-const-lower"}
84 {"Move \"either\" glob_const to .lower.rodata" "-T msp430.ld --data-region=lower"
85 "" "" {main-with-text-rodata.s} {{objdump -D main-const-lower.d}} "main-const-lower"}
88 set msp430regionprefixuniquesectiontests {
89 {"Move main() to .upper.text, with -ffunction/data-sections" "-T msp430.ld --code-region=upper"
90 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -d main-text-upper.d}} "main-upper"}
91 {"Move main() to .upper.text. No .lower.text in ld script, with -ffunction/data-sections" "-T msp430-no-lower.ld --code-region=upper"
92 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -d main-text-upper.d}} "main-upper"}
93 {"Move main() to .lower.text, with -ffunction/data-sections" "-T msp430.ld --code-region=lower"
94 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -d main-text-lower.d}} "main-lower"}
95 {"Move \"either\" main() to .lower.text, with -ffunction/data-sections" "-T msp430.ld --code-region=either"
96 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -d main-text-lower.d}} "main-either"}
98 {"Move glob_var to .upper.data, with -ffunction/data-sections" "-T msp430.ld --data-region=upper"
99 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-var-upper.d}} "main-var-upper"}
100 {"Move glob_var to .upper.data. No .lower.data in ld script, with -ffunction/data-sections" "-T msp430-no-lower.ld --data-region=upper"
101 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-var-upper.d}} "main-var-upper"}
102 {"Move glob_var to .lower.data, with -ffunction/data-sections" "-T msp430.ld --data-region=lower"
103 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-var-lower.d}} "main-var-lower"}
104 {"Move \"either\" glob_var to .lower.data, with -ffunction/data-sections" "-T msp430.ld --data-region=lower"
105 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-var-lower.d}} "main-var-lower"}
107 {"Move glob_zero to .upper.bss, with -ffunction/data-sections" "-T msp430.ld --data-region=upper"
108 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-bss-upper.d}} "main-bss-upper"}
109 {"Move glob_zero to .upper.bss. No .lower.bss in ld script., with -ffunction/data-sections" "-T msp430-no-lower.ld --data-region=upper"
110 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-bss-upper.d}} "main-bss-upper"}
111 {"Move glob_zero to .lower.bss, with -ffunction/data-sections" "-T msp430.ld --data-region=lower"
112 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-bss-lower.d}} "main-bss-lower"}
113 {"Move \"either\" glob_zero to .lower.bss, with -ffunction/data-sections" "-T msp430.ld --data-region=lower"
114 "" "" {main-with-data-bss-unique-sec.s} {{objdump -D main-bss-lower.d}} "main-bss-lower"}
116 {"Move glob_const to .upper.rodata, with -ffunction/data-sections" "-T msp430.ld --data-region=upper"
117 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -D main-const-upper.d}} "main-const-upper"}
118 {"Move glob_const to .upper.rodata. No .lower.rodata in ld script., with -ffunction/data-sections" "-T msp430-no-lower.ld --data-region=upper"
119 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -D main-const-upper.d}} "main-const-upper"}
120 {"Move glob_const to .lower.rodata, with -ffunction/data-sections" "-T msp430.ld --data-region=lower"
121 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -D main-const-lower.d}} "main-const-lower"}
122 {"Move \"either\" glob_const to .lower.rodata, with -ffunction/data-sections" "-T msp430.ld --data-region=lower"
123 "" "" {main-with-text-rodata-unique-sec.s} {{objdump -D main-const-lower.d}} "main-const-lower"}
126 set msp430eithershuffletests {
127 {"Move \"either\" main() to .upper.text when it doesn\'t fit in .lower.text"
128 "-T msp430-tiny-rom.ld --code-region=either --data-region=either" "" "" {main-with-text-rodata.s}
129 {{objdump -d main-text-upper.d}} "either-to-upper-text"}
130 {"Move \"either\" glob_var_array to .upper.data when it doesn\'t fit in .lower.data"
131 "-T msp430-tiny-ram.ld --data-region=either" "" "" {main-with-data-bss.s}
132 {{objdump -D main-var-upper.d}} "either-to-upper-data"}
133 {"Move \"either\" glob_bss_array to .upper.bss when it doesn\'t fit in .lower.bss"
134 "-T msp430-tiny-ram.ld --data-region=either" "" "" {main-with-data-bss.s}
135 {{objdump -D main-bss-upper.d}} "either-to-upper-bss"}
136 {"Move \"either\" glob_const_array to .upper.rodata when it doesn\'t fit in .lower.rodata"
137 "-T msp430-tiny-rom.ld --code-region=either --data-region=either" "" "" {main-with-text-rodata.s}
138 {{objdump -D main-const-upper.d}} "either-to-upper-const"}
140 {"Move \"either\" main() to .upper.text when it doesn\'t fit in .lower.text, with -ffunction/data-sections"
141 "-T msp430-tiny-rom.ld --code-region=either --data-region=either" "" "" {main-with-text-rodata-unique-sec.s}
142 {{objdump -d main-text-upper.d}} "either-to-upper-text-unique-sec"}
143 {"Move \"either\" glob_var_array to .upper.data when it doesn\'t fit in .lower.data, with -ffunction/data-sections"
144 "-T msp430-tiny-ram.ld --data-region=either" "" "" {main-with-data-bss-unique-sec.s}
145 {{objdump -D main-var-upper.d}} "either-to-upper-data-unique-sec"}
146 {"Move \"either\" glob_bss_array to .upper.bss when it doesn\'t fit in .lower.bss, with -ffunction/data-sections"
147 "-T msp430-tiny-ram.ld --data-region=either" "" "" {main-with-data-bss-unique-sec.s}
148 {{objdump -D main-bss-upper.d}} "either-to-upper-bss-unique-sec"}
149 {"Move \"either\" glob_const_array to .upper.rodata when it doesn\'t fit in .lower.rodata, with -ffunction/data-sections"
150 "-T msp430-tiny-rom.ld --code-region=either --data-region=either" "" "" {main-with-text-rodata-unique-sec.s}
151 {{objdump -D main-const-upper.d}} "either-to-upper-const-unique-sec"}
154 set msp430warntests {
155 {"Warn when section cannot be transformed because output section does not exist in linker script (text,data,bss,rodata)"
156 "-T msp430-no-lower.ld --code-region=lower --data-region=lower" "" "" {warn-no-lower.s}
157 {{ld warn-no-lower.r}} "warn-no-lower"}
158 {"Warn when section cannot be transformed because output section does not exist in linker script (text only)"
159 "-T msp430-no-lower.ld --code-region=lower" "" "" {warn-no-lower.s}
160 {{ld warn-no-lower-code.r}} "warn-no-lower-code"}
161 {"Warn when section cannot be transformed because output section does not exist in linker script (data,bss,rodata)"
162 "-T msp430-no-lower.ld --data-region=lower" "" "" {warn-no-lower.s}
163 {{ld warn-no-lower-data.r}} "warn-no-lower-data"}
166 set msp430arraytests {
167 { "Warn when __preinit_array_start is not word aligned" "-T preinitarray-warn.ld" "" ""
168 {initarray.s} {{ld preinitarray-warn.r}} "preinitarray-warn"}
169 { "Warn when __init_array_start is not word aligned" "-T initarray-warn.ld" "" ""
170 {initarray.s} {{ld initarray-warn.r}} "initarray-warn"}
171 { "Warn when __fini_array_start is not word aligned" "-T finiarray-warn.ld" "" ""
172 {initarray.s} {{ld finiarray-warn.r}} "finiarray-warn"}
173 { "Don't warn when __
{preinit
,init
,fini
}_array_start are word aligned
" "-T initarray-nowarn.ld" "" ""
174 {initarray.s
} {{ld initarray
-nowarn.r
}} "initarray-nowarn"}
177 run_ld_link_tests $msp430arraytests
179 run_dump_test uleb128_430
180 run_dump_test uleb128_430x
182 # Don
't run further tests when msp430 ISA is selected
183 if {[string match "*-mcpu=msp430 *" [board_info [target_info name] multilib_flags]]
184 || [string match "*-mcpu=msp430" [board_info [target_info name] multilib_flags]]} {
187 run_ld_link_tests $msp430regionprefixtests
188 run_ld_link_tests $msp430regionprefixuniquesectiontests
189 run_ld_link_tests $msp430eithershuffletests
190 run_ld_link_tests $msp430warntests
192 run_dump_test valid-map
193 run_ld_link_tests {{ "Check no reloc overflow with #lo and data in the upper region"
194 "-m msp430X" "" "" {reloc-lo-430x.s} {} "reloc-lo-430x"}}
195 run_ld_link_tests {{ "Check .upper prefixed input sections can be placed"
196 "-m msp430X" "" "" {upper-input-sections.s} {} "upper-input-sections"}}
198 # Don't run data region tests
if a data region is specified
199 if {[string match
"*-mdata-region*" [board_info [target_info name] multilib_flags]]} {
202 # GNU object attribute dump tests
203 run_dump_test attr
-gnu
-region
-lower
204 run_dump_test attr
-gnu
-region
-upper
205 run_dump_test attr
-gnu
-region
-lower
-upper