Replace "use use" in a warning message with "use".
[deliverable/binutils-gdb.git] / ld / genscripts.sh
CommitLineData
252b5132
RH
1#!/bin/sh
2# genscripts.sh - generate the ld-emulation-target specific files
b3adc24a 3# Copyright (C) 2004-2020 Free Software Foundation, Inc.
f96b4a7b
NC
4#
5# This file is part of the Gnu Linker.
6#
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, or (at your option)
10# any later version.
11#
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.
16#
17# You should have received a copy of the GNU General Public License
18# along with GLD; see the file COPYING. If not, write to the Free
19# Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20# 02110-1301, USA.
252b5132 21#
8fbdf3ab
AM
22# Usage: genscripts_extra.sh \
23# srcdir \
24# libdir \
dfcffada 25# prefix \
8fbdf3ab
AM
26# exec_prefix \
27# host \
28# target \
29# target_alias \
30# default_emulation \
31# native_lib_dirs \
32# use_sysroot \
02ecc8e9 33# enable_initfini_array \
8fbdf3ab
AM
34# this_emulation \
35# optional:
ce46249c 36# tool_dir
252b5132
RH
37#
38# Sample usage:
8fbdf3ab
AM
39#
40# genscripts_extra.sh \
41# /sources/ld \
42# /usr/local/lib \
43# /usr/local \
dfcffada 44# /usr/local \
8fbdf3ab
AM
45# sparc-sun-sunos4.1.3 \
46# sparc-sun-sunos4.1.3 \
47# sparc-sun-sunos4.1.3 \
48# sun4 \
49# "" \
50# no \
51# sun3 \
52# sparc-sun-sunos4.1.3 \
53# sparc.sh
54#
55# produces the linker scripts:
56#
57# sun3.x [default linker script]
58# sun3.xbn [used when the linker is invoked with "-N"]
59# sun3.xn [used when the linker is invoked with "-n"]
60# sun3.xr [used when the linker is invoked with "-r"]
61# sun3.xu [used when the linker is invoked with "-Ur"]
a3813728
AK
62#
63# depending on platform specific settings linker scripts with the
64# following suffixes might be generated as well:
65#
dfde93ab 66# xdwe: -pie -z combreloc -z separate-code -z relro -z now
a3813728
AK
67# xdw: -pie -z combreloc -z relro -z now
68# xdceo: -pie -z combreloc -z separate-code -z relro
69# xdce: -pie -z combreloc -z separate-code
70# xdco: -pie -z combreloc -z relro
71# xdc: -pie -z combreloc
72# xdeo: -pie -z separate-code -z relro
73# xde: -pie -z separate-code
74# xdo: -pie -z relro
75# xd: -pie
76#
dfde93ab 77# xswe: -shared -z combreloc -z separate-code -z relro -z now
a3813728
AK
78# xsw: -shared -z combreloc -z relro -z now
79# xsceo: -shared -z combreloc -z separate-code -z relro
80# xsce: -shared -z combreloc -z separate-code
81# xsco: -shared -z combreloc -z relro
82# xsc: -shared -z combreloc
83# xseo: -shared -z separate-code -z relro
84# xse: -shared -z separate-code
85# xso: -shared -z relro
86# xs: -shared
87#
dfde93ab 88# xwe: -z combreloc -z separate-code -z relro -z now
a3813728
AK
89# xw: -z combreloc -z relro -z now
90# xceo: -z combreloc -z separate-code -z relro
91# xce: -z combreloc -z separate-code
92# xco: -z combreloc -z relro
93# xc: -z combreloc
94# xeo: -z separate-code -z relro
95# xe: -z separate-code
96# xo: -z relro
97#
8fbdf3ab
AM
98#
99# It also produced the C source file:
100#
101# em_sun3.c
102#
103# which is then compiled into the linker.
104#
105# The linker scripts are created by running the shell script
106# /sources/ld/emulparams/sparc.sh to set the value of ${SCRIPT_NAME}
107# (and any other variables it wants to). ${SCRIPT_NAME} is then
108# invoked with a variable called ${LD_FLAG} to tell it which version
109# of the linker script to create.
110
252b5132
RH
111
112srcdir=$1
113libdir=$2
dfcffada
AM
114prefix=$3
115exec_prefix=$4
116host=$5
117target=$6
118target_alias=$7
c40e31a1
AM
119DEPDIR=$8
120shift 8
121LIB_PATH=$1
122EMULATION_LIBPATH=$2
123NATIVE_LIB_DIRS=$3
124use_sysroot=$4
125ENABLE_INITFINI_ARRAY=$5
126shift 5
127EMULATION_NAME=$1
128TOOL_LIB=$2
129
130source_sh()
131{
cc9519e7
AM
132 if test -n "${DEPDIR}"; then
133 echo $1 >> ${DEPDIR}/e${EMULATION_NAME}.Tc
134 fi
c40e31a1
AM
135 . $1
136}
137
cc9519e7
AM
138if test -n "${DEPDIR}"; then
139 rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
140fi
252b5132
RH
141
142# Include the emulation-specific parameters:
ce46249c 143CUSTOMIZER_SCRIPT="${srcdir}/emulparams/${EMULATION_NAME}.sh"
c40e31a1 144source_sh ${CUSTOMIZER_SCRIPT}
252b5132
RH
145
146if test -d ldscripts; then
147 true
148else
149 mkdir ldscripts
150fi
151
9c8ebd6a
DJ
152# Set some flags for the emultempl scripts. USE_LIBPATH will
153# be set for any libpath-using emulation; NATIVE will be set for a
154# libpath-using emulation where ${host} = ${target}. NATIVE
155# may already have been set by the emulparams file, but that's OK
156# (it'll just get set to "yes" twice).
157
158case " $EMULATION_LIBPATH " in
159 *" ${EMULATION_NAME} "*)
160 if [ "x${host}" = "x${target}" ] ; then
161 NATIVE=yes
162 USE_LIBPATH=yes
163 elif [ "x${use_sysroot}" = "xyes" ] ; then
164 USE_LIBPATH=yes
165 fi
166 ;;
167esac
168
169# If the emulparams file sets NATIVE, make sure USE_LIBPATH is set also.
170if test "x$NATIVE" = "xyes" ; then
171 USE_LIBPATH=yes
172fi
173
252b5132
RH
174# Set the library search path, for libraries named by -lfoo.
175# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
176# Otherwise, the default is set here.
177#
178# The format is the usual list of colon-separated directories.
179# To force a logically empty LIB_PATH, do LIBPATH=":".
9c8ebd6a
DJ
180#
181# If we are using a sysroot, prefix library paths with "=" to indicate this.
182#
183# If the emulparams file set LIBPATH_SUFFIX, prepend an extra copy of
184# the library path with the suffix applied.
252b5132 185
0f70b6b5
AM
186# Paths with LIBPATH_SUFFIX
187lib_path1=
188# Paths without LIBPATH_SUFFIX
189lib_path2=
190if [ "${LIB_PATH}" != ":" ] ; then
191 lib_path2=${LIB_PATH}
192fi
1dd3bf68 193
0f70b6b5
AM
194# Add args to lib_path1 and lib_path2, discarding any duplicates
195append_to_lib_path()
196{
197 if [ $# != 0 ]; then
198 for lib in "$@"; do
199 # The "=" is harmless if we aren't using a sysroot, but also needless.
200 if [ "x${use_sysroot}" = "xyes" ] ; then
201 lib="=${lib}"
202 fi
f6f6c679 203 skip_lib=no
10d98088 204 for libpath_suffix in ${LIBPATH_SUFFIX}; do
0f70b6b5 205 case "${lib}" in
10d98088 206 *${libpath_suffix})
0f70b6b5
AM
207 case :${lib_path1}: in
208 *:${lib}:*) ;;
209 ::) lib_path1=${lib} ;;
210 *) lib_path1=${lib_path1}:${lib} ;;
211 esac ;;
212 *)
f6f6c679
L
213 if test -n "${LIBPATH_SUFFIX_SKIP}"; then
214 case "${lib}" in
215 *${LIBPATH_SUFFIX_SKIP}) skip_lib=yes ;;
216 esac
217 fi
218 if test "${skip_lib}" = "no"; then
219 case :${lib_path1}: in
10d98088
JW
220 *:${lib}${libpath_suffix}:*) ;;
221 ::) lib_path1=${lib}${libpath_suffix} ;;
222 *) lib_path1=${lib_path1}:${lib}${libpath_suffix} ;;
f6f6c679
L
223 esac
224 fi ;;
225 esac
10d98088 226 done
f6f6c679
L
227 if test "${skip_lib}" = "no"; then
228 case :${lib_path1}:${lib_path2}: in
229 *:${lib}:*) ;;
230 *::) lib_path2=${lib} ;;
231 *) lib_path2=${lib_path2}:${lib} ;;
0f70b6b5
AM
232 esac
233 fi
0f70b6b5
AM
234 done
235 fi
236}
237
238# Always search $(tooldir)/lib, aka /usr/local/TARGET/lib when native
239# except when LIBPATH=":".
240if [ "${LIB_PATH}" != ":" ] ; then
241 libs=
242 if [ "x${TOOL_LIB}" = "x" ] ; then
243 if [ "x${NATIVE}" = "xyes" ] ; then
244 libs="${exec_prefix}/${target_alias}/lib"
d460ab58 245 fi
0f70b6b5
AM
246 else
247 # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
248 # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} are in the default search path,
249 # because 64bit libraries may be in both places, depending on
250 # cross-development setup method (e.g.: /usr/s390x-linux/lib64
251 # vs. /usr/s390-linux/lib64)
10d98088
JW
252 for libpath_suffix in ${LIBPATH_SUFFIX}; do
253 case "${NATIVE}:${libpath_suffix}:${TOOL_LIB}" in
254 :* | *::* | *:*:*${libpath_suffix}) ;;
255 *) libs="${exec_prefix}/${target_alias}/lib${libpath_suffix}" ;;
256 esac
257 done
0f70b6b5
AM
258 libs="${exec_prefix}/${TOOL_LIB}/lib ${libs}"
259 fi
260 append_to_lib_path ${libs}
252b5132
RH
261fi
262
0f70b6b5
AM
263if [ "x${LIB_PATH}" = "x" ] && [ "x${USE_LIBPATH}" = xyes ] ; then
264 libs=${NATIVE_LIB_DIRS}
265 if [ "x${NATIVE}" = "xyes" ] ; then
266 case " ${libs} " in
267 *" ${libdir} "*) ;;
268 *) libs="${libdir} ${libs}" ;;
33423b7f
MF
269 esac
270 fi
0f70b6b5 271 append_to_lib_path ${libs}
9c8ebd6a 272fi
252b5132 273
0f70b6b5
AM
274case :${lib_path1}:${lib_path2}: in
275 *:: | ::*) LIB_PATH=${lib_path1}${lib_path2} ;;
276 *) LIB_PATH=${lib_path1}:${lib_path2} ;;
277esac
278
eb3d6bb8 279LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
252b5132 280
cdaeef2e 281# We need it for testsuite.
dc4f76f8
L
282set $EMULATION_LIBPATH
283if [ "x$1" = "x$EMULATION_NAME" ]; then
cdaeef2e 284 test -d tmpdir || mkdir tmpdir
dc4f76f8 285 rm -f tmpdir/libpath.exp
cdaeef2e 286 echo "set libpath \"${LIB_PATH}\"" | sed -e 's/:/ /g' > tmpdir/libpath.exp
dc4f76f8 287fi
cdaeef2e 288
db6751f2
JJ
289if [ "x$SCRIPT_NAME" = "xelf" ]; then
290 GENERATE_COMBRELOC_SCRIPT=yes
291fi
252b5132 292
1ddd7b13 293SEGMENT_SIZE=${SEGMENT_SIZE-${MAXPAGESIZE-${TARGET_PAGE_SIZE}}}
252b5132
RH
294
295# Determine DATA_ALIGNMENT for the 5 variants, using
8fbdf3ab 296# values specified in the emulparams/<script_to_run>.sh file or default.
252b5132
RH
297
298DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}"
299DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}"
300DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}"
301DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}"
302DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
303
304LD_FLAG=r
305DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
306DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
dfde93ab 307( echo "/* Script for -r */"
c40e31a1
AM
308 source_sh ${CUSTOMIZER_SCRIPT}
309 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 310) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xr
252b5132
RH
311
312LD_FLAG=u
313DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
314CONSTRUCTING=" "
dfde93ab 315( echo "/* Script for -Ur */"
c40e31a1
AM
316 source_sh ${CUSTOMIZER_SCRIPT}
317 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 318) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu
252b5132 319
252b5132
RH
320DATA_ALIGNMENT=${DATA_ALIGNMENT_}
321RELOCATING=" "
47acac12 322LD_FLAG=
cedd6b0d 323( echo "/* Default linker script, for normal executables */"
c40e31a1
AM
324 source_sh ${CUSTOMIZER_SCRIPT}
325 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 326) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.x
252b5132 327
47acac12 328LD_FLAG=textonly
dfde93ab 329( echo "/* Script for -z separate-code */"
c40e31a1
AM
330 source_sh ${CUSTOMIZER_SCRIPT}
331 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
332) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xe
333
a3813728
AK
334if test -n "$GENERATE_RELRO_SCRIPT"; then
335 LD_FLAG=
336 RELRO=" "
dfde93ab 337 ( echo "/* Script for -z relro */"
c40e31a1
AM
338 source_sh ${CUSTOMIZER_SCRIPT}
339 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
340 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xo
341 LD_FLAG=textonly
dfde93ab 342 ( echo "/* Script for -z separate-code -z relro */"
c40e31a1
AM
343 source_sh ${CUSTOMIZER_SCRIPT}
344 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
345 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xeo
346 unset RELRO
347fi
252b5132
RH
348LD_FLAG=n
349DATA_ALIGNMENT=${DATA_ALIGNMENT_n}
dfde93ab 350( echo "/* Script for -n */"
c40e31a1
AM
351 source_sh ${CUSTOMIZER_SCRIPT}
352 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 353) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xn
252b5132
RH
354
355LD_FLAG=N
356DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
dfde93ab 357( echo "/* Script for -N */"
c40e31a1
AM
358 source_sh ${CUSTOMIZER_SCRIPT}
359 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 360) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xbn
db6751f2
JJ
361
362if test -n "$GENERATE_COMBRELOC_SCRIPT"; then
363 DATA_ALIGNMENT=${DATA_ALIGNMENT_c-${DATA_ALIGNMENT_}}
364 LD_FLAG=c
365 COMBRELOC=ldscripts/${EMULATION_NAME}.xc.tmp
dfde93ab 366 ( echo "/* Script for -z combreloc */"
c40e31a1
AM
367 source_sh ${CUSTOMIZER_SCRIPT}
368 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 369 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xc
db6751f2 370 rm -f ${COMBRELOC}
47acac12
L
371 LD_FLAG=ctextonly
372 COMBRELOC=ldscripts/${EMULATION_NAME}.xce.tmp
dfde93ab 373 ( echo "/* Script for -z combreloc -z separate-code */"
c40e31a1
AM
374 source_sh ${CUSTOMIZER_SCRIPT}
375 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
376 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xce
377 rm -f ${COMBRELOC}
8c37241b 378 RELRO_NOW=" "
47acac12 379 LD_FLAG=w
8c37241b 380 COMBRELOC=ldscripts/${EMULATION_NAME}.xw.tmp
dfde93ab 381 ( echo "/* Script for -z combreloc -z relro -z now */"
c40e31a1
AM
382 source_sh ${CUSTOMIZER_SCRIPT}
383 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 384 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xw
8c37241b 385 rm -f ${COMBRELOC}
47acac12
L
386 LD_FLAG=wtextonly
387 COMBRELOC=ldscripts/${EMULATION_NAME}.xwe.tmp
dfde93ab 388 ( echo "/* Script for -z combreloc -z separate-code -z relro -z now */"
c40e31a1
AM
389 source_sh ${CUSTOMIZER_SCRIPT}
390 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
391 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xwe
392 rm -f ${COMBRELOC}
db6751f2 393 COMBRELOC=
8c37241b 394 unset RELRO_NOW
a3813728
AK
395 if test -n "$GENERATE_RELRO_SCRIPT"; then
396 LD_FLAG=c
397 RELRO=" "
398 COMBRELOC=ldscripts/${EMULATION_NAME}.xco.tmp
dfde93ab 399 ( echo "/* Script for -z combreloc -z relro */"
c40e31a1
AM
400 source_sh ${CUSTOMIZER_SCRIPT}
401 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
402 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xco
403 rm -f ${COMBRELOC}
404 LD_FLAG=ctextonly
405 COMBRELOC=ldscripts/${EMULATION_NAME}.xceo.tmp
dfde93ab 406 ( echo "/* Script for -z combreloc -z separate-code -z relro */"
c40e31a1
AM
407 source_sh ${CUSTOMIZER_SCRIPT}
408 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
409 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xceo
410 rm -f ${COMBRELOC}
411 COMBRELOC=
412 unset RELRO
413 fi
db6751f2 414fi
252b5132
RH
415
416if test -n "$GENERATE_SHLIB_SCRIPT"; then
252b5132
RH
417 DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}}
418 CREATE_SHLIB=" "
47acac12 419 LD_FLAG=shared
dfde93ab 420 ( echo "/* Script for -shared */"
c40e31a1
AM
421 source_sh ${CUSTOMIZER_SCRIPT}
422 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 423 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xs
47acac12 424 LD_FLAG=sharedtextonly
dfde93ab 425 ( echo "/* Script for -shared -z separate-code */"
c40e31a1
AM
426 source_sh ${CUSTOMIZER_SCRIPT}
427 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12 428 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xse
a3813728
AK
429
430 if test -n "$GENERATE_RELRO_SCRIPT"; then
431 RELRO=" "
432 LD_FLAG=shared
dfde93ab 433 ( echo "/* Script for -shared -z relro */"
c40e31a1
AM
434 source_sh ${CUSTOMIZER_SCRIPT}
435 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
436 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xso
437 LD_FLAG=sharedtextonly
dfde93ab 438 ( echo "/* Script for -shared -z separate-code -z relro */"
c40e31a1
AM
439 source_sh ${CUSTOMIZER_SCRIPT}
440 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
441 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xseo
442 unset RELRO
443 fi
db6751f2 444 if test -n "$GENERATE_COMBRELOC_SCRIPT"; then
db6751f2 445 DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}}
47acac12 446 LD_FLAG=cshared
8c37241b 447 COMBRELOC=ldscripts/${EMULATION_NAME}.xsc.tmp
dfde93ab 448 ( echo "/* Script for -shared -z combreloc */"
c40e31a1
AM
449 source_sh ${CUSTOMIZER_SCRIPT}
450 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 451 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc
db6751f2 452 rm -f ${COMBRELOC}
47acac12
L
453 LD_FLAG=csharedtextonly
454 COMBRELOC=ldscripts/${EMULATION_NAME}.xsce.tmp
dfde93ab 455 ( echo "/* Script for -shared -z combreloc -z separate-code */"
c40e31a1
AM
456 source_sh ${CUSTOMIZER_SCRIPT}
457 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
458 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsce
459 rm -f ${COMBRELOC}
8c37241b 460 RELRO_NOW=" "
47acac12 461 LD_FLAG=wshared
8c37241b 462 COMBRELOC=ldscripts/${EMULATION_NAME}.xsw.tmp
dfde93ab 463 ( echo "/* Script for -shared -z combreloc -z relro -z now */"
c40e31a1
AM
464 source_sh ${CUSTOMIZER_SCRIPT}
465 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 466 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsw
8c37241b 467 rm -f ${COMBRELOC}
47acac12
L
468 LD_FLAG=wsharedtextonly
469 COMBRELOC=ldscripts/${EMULATION_NAME}.xswe.tmp
dfde93ab 470 ( echo "/* Script for -shared -z combreloc -z separate-code -z relro -z now */"
c40e31a1
AM
471 source_sh ${CUSTOMIZER_SCRIPT}
472 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
473 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xswe
474 rm -f ${COMBRELOC}
8c37241b 475 unset RELRO_NOW
a3813728
AK
476
477 if test -n "$GENERATE_RELRO_SCRIPT"; then
478 LD_FLAG=wshared
479 RELRO=" "
480 COMBRELOC=ldscripts/${EMULATION_NAME}.xsco.tmp
dfde93ab 481 ( echo "/* Script for -shared -z combreloc -z relro */"
c40e31a1
AM
482 source_sh ${CUSTOMIZER_SCRIPT}
483 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
484 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsco
485 rm -f ${COMBRELOC}
486 LD_FLAG=wsharedtextonly
487 COMBRELOC=ldscripts/${EMULATION_NAME}.xsceo.tmp
dfde93ab 488 ( echo "/* Script for -shared -z combreloc -z separate-code -z relro */"
c40e31a1
AM
489 source_sh ${CUSTOMIZER_SCRIPT}
490 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
491 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsceo
492 rm -f ${COMBRELOC}
493 unset RELRO
494 fi
495 COMBRELOC=
db6751f2 496 fi
36af4a4e
JJ
497 unset CREATE_SHLIB
498fi
499
500if test -n "$GENERATE_PIE_SCRIPT"; then
36af4a4e
JJ
501 DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}}
502 CREATE_PIE=" "
47acac12 503 LD_FLAG=pie
dfde93ab 504 ( echo "/* Script for -pie */"
c40e31a1
AM
505 source_sh ${CUSTOMIZER_SCRIPT}
506 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 507 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xd
47acac12 508 LD_FLAG=pietextonly
dfde93ab 509 ( echo "/* Script for -pie -z separate-code */"
c40e31a1
AM
510 source_sh ${CUSTOMIZER_SCRIPT}
511 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12 512 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xde
a3813728
AK
513 if test -n "$GENERATE_RELRO_SCRIPT"; then
514 RELRO=" "
515 LD_FLAG=pie
dfde93ab 516 ( echo "/* Script for -pie -z relro */"
c40e31a1
AM
517 source_sh ${CUSTOMIZER_SCRIPT}
518 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
519 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdo
520 LD_FLAG=pietextonly
dfde93ab 521 ( echo "/* Script for -pie -z separate-code -z relro */"
c40e31a1
AM
522 source_sh ${CUSTOMIZER_SCRIPT}
523 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
524 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdeo
525 unset RELRO
526 fi
36af4a4e 527 if test -n "$GENERATE_COMBRELOC_SCRIPT"; then
36af4a4e 528 DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}}
8c37241b 529 COMBRELOC=ldscripts/${EMULATION_NAME}.xdc.tmp
47acac12 530 LD_FLAG=cpie
dfde93ab 531 ( echo "/* Script for -pie -z combreloc */"
c40e31a1
AM
532 source_sh ${CUSTOMIZER_SCRIPT}
533 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 534 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdc
36af4a4e 535 rm -f ${COMBRELOC}
47acac12
L
536 LD_FLAG=cpietextonly
537 COMBRELOC=ldscripts/${EMULATION_NAME}.xdce.tmp
dfde93ab 538 ( echo "/* Script for -pie -z combreloc -z separate-code */"
c40e31a1
AM
539 source_sh ${CUSTOMIZER_SCRIPT}
540 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
541 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdce
542 rm -f ${COMBRELOC}
8c37241b 543 RELRO_NOW=" "
47acac12 544 LD_FLAG=wpie
8c37241b 545 COMBRELOC=ldscripts/${EMULATION_NAME}.xdw.tmp
dfde93ab 546 ( echo "/* Script for -pie -z combreloc -z relro -z now */"
c40e31a1
AM
547 source_sh ${CUSTOMIZER_SCRIPT}
548 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 549 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdw
8c37241b 550 rm -f ${COMBRELOC}
47acac12
L
551 LD_FLAG=wpietextonly
552 COMBRELOC=ldscripts/${EMULATION_NAME}.xdwe.tmp
dfde93ab 553 ( echo "/* Script for -pie -z combreloc -z separate-code -z relro -z now */"
c40e31a1
AM
554 source_sh ${CUSTOMIZER_SCRIPT}
555 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
47acac12
L
556 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdwe
557 rm -f ${COMBRELOC}
8c37241b 558 unset RELRO_NOW
a3813728
AK
559
560 if test -n "$GENERATE_RELRO_SCRIPT"; then
561 LD_FLAG=wpie
562 RELRO=" "
563 COMBRELOC=ldscripts/${EMULATION_NAME}.xdco.tmp
dfde93ab 564 ( echo "/* Script for -pie -z combreloc -z relro */"
c40e31a1
AM
565 source_sh ${CUSTOMIZER_SCRIPT}
566 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
567 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdco
568 rm -f ${COMBRELOC}
569 LD_FLAG=wpietextonly
570 COMBRELOC=ldscripts/${EMULATION_NAME}.xdceo.tmp
dfde93ab 571 ( echo "/* Script for -pie -z combreloc -z separate-code -z relro */"
c40e31a1
AM
572 source_sh ${CUSTOMIZER_SCRIPT}
573 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
a3813728
AK
574 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdceo
575 rm -f ${COMBRELOC}
576
577 unset RELRO
578 fi
579 COMBRELOC=
36af4a4e
JJ
580 fi
581 unset CREATE_PIE
252b5132
RH
582fi
583
e2a83dd0
NC
584if test -n "$GENERATE_AUTO_IMPORT_SCRIPT"; then
585 LD_FLAG=auto_import
586 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
dfde93ab 587 ( echo "/* Script for --enable-auto-import */"
c40e31a1
AM
588 source_sh ${CUSTOMIZER_SCRIPT}
589 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
6c19b93b 590 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa
e2a83dd0
NC
591fi
592
7225345d
AM
593case "$COMPILE_IN: $EMULATION_LIBPATH " in
594 :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;;
eb3d6bb8 595esac
252b5132 596
6e73d595
NC
597# PR ld/5652:
598# Determine if the shell has support for the variable BASH_LINENO.
599# When it is the case, it is only available inside functions.
600has_lineno()
601{
602 test "x$BASH_LINENO" != "x"
603}
604
605# Enable accruate error source in the compiler error messages, if possible.
606if has_lineno; then
c43cc9ff 607 . ${srcdir}/genscrba.sh
92b93329
RM
608else
609 source_em()
610 {
c40e31a1 611 source_sh $1
92b93329
RM
612 }
613 fragment()
614 {
615 cat >> e${EMULATION_NAME}.c
616 }
617fi
618
252b5132 619# Generate e${EMULATION_NAME}.c.
92b93329
RM
620# Start with an empty file, then the sourced .em script
621# can use the "fragment" function to append.
622> e${EMULATION_NAME}.c
623source_em ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
c40e31a1 624
cc9519e7
AM
625if test -n "${DEPDIR}"; then
626 ecdeps=
627 for dep in `cat ${DEPDIR}/e${EMULATION_NAME}.Tc`; do
628 case " $ecdeps " in
629 *" $dep "*): ;;
630 *) ecdeps="$ecdeps $dep" ;;
631 esac
632 done
633 rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
634 echo "e${EMULATION_NAME}.c:${ecdeps}" > ${DEPDIR}/e${EMULATION_NAME}.Pc
635fi
This page took 0.888737 seconds and 4 git commands to generate.