1 # Expect script for LoongArch ELF linker tests
2 # Copyright (C) 2022-2023 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 loongarch*-*-*] {
27 set old_verbose verbose
30 # Check to see if the C compiler works
31 if { ![check_compiler_available] } {
36 set testname "nopic link test pre build"
37 set pre_builds [list \
40 "-shared $NOSANITIZE_CFLAGS" \
41 "-fPIC $NOSANITIZE_CFLAGS" \
44 "libnopic-global.so" \
51 # 3:filenames of source files
52 # 4:action and options.
53 # 5:name of output file
54 # 6:language (optional)
55 run_cc_link_tests $pre_builds
59 set testname "nopic link test"
61 set link_tests [list \
63 "$testname readelf -s/-x nopic-local" \
68 [list readelf -s nopic-local.sd] \
69 [list readelf "-x .data" nopic-local.xd] \
74 "$testname readelf -s/-x nopic-weak-local" \
77 {nopic-weak-local.s} \
79 [list readelf -s nopic-weak-local.sd] \
80 [list readelf "-x .data" nopic-weak-local.xd] \
85 "$testname readelf -s/-x nopic-global" \
88 {nopic-global.s libnopic-global.s} \
90 [list readelf -s nopic-global.sd] \
91 [list readelf "-x .data" nopic-global.xd] \
96 "$testname readelf -s/-r nopic-global-so" \
97 "-L./tmpdir -lnopic-global -L/usr/lib -lc" "" \
101 [list readelf -s nopic-global-so.sd] \
102 [list readelf -r nopic-global-so.rd] \
107 "$testname readelf -s/-x nopic-weak-global" \
110 {nopic-weak-global.s libnopic-global.s} \
112 [list readelf -s nopic-weak-global.sd] \
113 [list readelf "-x .data" nopic-weak-global.xd] \
115 "nopic-weak-global" \
118 "$testname readelf -s/-x nopic-weak-global-so" \
119 "-L./tmpdir -lnopic-global -L/usr/lib -lc" "" \
121 {nopic-weak-global.s} \
123 [list readelf -s nopic-weak-global-so.sd] \
124 [list readelf -r nopic-weak-global-so.rd] \
126 "nopic-weak-global-so" \
131 # 1:ld/ar leading options, placed before object files
132 # 2:ld/ar trailing options, placed after object files
133 # 3:assembler options
134 # 4:filenames of assembler files
135 # 5:list of actions, options and expected outputs.
136 # 6:name of output file
137 # 7:compiler flags (optional)
138 run_ld_link_tests $link_tests
140 set testname "nopic link exec test"
142 set link_exec_tests [list \
153 { nopic-weak-local.s } \
155 "nopic-weak-local.out" \
160 { nopic-global.s libnopic-global.s } \
166 "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" "" \
174 { nopic-weak-global.s libnopic-global.s } \
175 "nopic-weak-global" \
176 "nopic-weak-global.out" \
180 "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" "" \
181 { nopic-weak-global.s } \
182 "nopic-weak-global-so" \
183 "nopic-weak-global.out" \
187 # ldtests contains test-items with 3 items followed by 1 lists, 2 items
188 # and 3 optional items:
190 # 1:ld leading options, placed before object files
191 # 2:assembler options
192 # 3:filenames of source files
193 # 4:name of output file
195 # 6:compiler flags (optional)
196 # 7:language (optional)
197 # 8:linker warning (optional)
198 # 9:ld trailing options, placed after object files (optional)
199 run_ld_link_exec_tests $link_exec_tests
202 #set verbose old_verbose