Implement tp_richcompare for gdb.Block
[binutils-gdb.git] / ld / genscripts.sh
blobd6ceb3fe4f56bfd02bada18804175858deedd3e4
1 #!/bin/sh
2 # genscripts.sh - generate the ld-emulation-target specific files
3 # Copyright (C) 2004-2024 Free Software Foundation, Inc.
5 # This file is part of the Gnu Linker.
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.
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 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.
22 # Usage: genscripts_extra.sh \
23 # srcdir \
24 # libdir \
25 # prefix \
26 # exec_prefix \
27 # host \
28 # target \
29 # target_alias \
30 # default_emulation \
31 # native_lib_dirs \
32 # use_sysroot \
33 # enable_initfini_array \
34 # this_emulation \
35 # optional:
36 # tool_dir
38 # Sample usage:
40 # genscripts_extra.sh \
41 # /sources/ld \
42 # /usr/local/lib \
43 # /usr/local \
44 # /usr/local \
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
55 # produces the linker scripts:
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"]
63 # depending on platform specific settings linker scripts with the
64 # following suffixes might be generated as well:
66 # xdwe: -pie -z combreloc -z separate-code -z relro -z now
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
77 # xswe: -shared -z combreloc -z separate-code -z relro -z now
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
88 # xwe: -z combreloc -z separate-code -z relro -z now
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
99 # It also produced the C source file:
101 # em_sun3.c
103 # which is then compiled into the linker.
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.
112 srcdir=$1
113 libdir=$2
114 prefix=$3
115 exec_prefix=$4
116 host=$5
117 target=$6
118 target_alias=$7
119 DEPDIR=$8
120 shift 8
121 LIB_PATH=$1
122 EMULATION_LIBPATH=$2
123 NATIVE_LIB_DIRS=$3
124 use_sysroot=$4
125 ENABLE_INITFINI_ARRAY=$5
126 shift 5
127 EMULATION_NAME=$1
128 TOOL_LIB=$2
130 source_sh()
132 if test -n "${DEPDIR}"; then
133 echo $1 >> ${DEPDIR}/e${EMULATION_NAME}.Tc
135 . $1
138 if test -n "${DEPDIR}"; then
139 rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
142 # Include the emulation-specific parameters:
143 CUSTOMIZER_SCRIPT="${srcdir}/emulparams/${EMULATION_NAME}.sh"
144 source_sh ${CUSTOMIZER_SCRIPT}
146 # Set some flags for the emultempl scripts. USE_LIBPATH will
147 # be set for any libpath-using emulation; NATIVE will be set for a
148 # libpath-using emulation where ${host} = ${target}. NATIVE
149 # may already have been set by the emulparams file, but that's OK
150 # (it'll just get set to "yes" twice).
152 case " $EMULATION_LIBPATH " in
153 *" ${EMULATION_NAME} "*)
154 if [ "x${host}" = "x${target}" ] ; then
155 NATIVE=yes
156 USE_LIBPATH=yes
157 elif [ "x${use_sysroot}" = "xyes" ] ; then
158 USE_LIBPATH=yes
161 esac
163 # If the emulparams file sets NATIVE, make sure USE_LIBPATH is set also.
164 if test "x$NATIVE" = "xyes" ; then
165 USE_LIBPATH=yes
168 # Set the library search path, for libraries named by -lfoo.
169 # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
170 # Otherwise, the default is set here.
172 # The format is the usual list of colon-separated directories.
173 # To force a logically empty LIB_PATH, do LIBPATH=":".
175 # If we are using a sysroot, prefix library paths with "=" to indicate this.
177 # If the emulparams file set LIBPATH_SUFFIX, prepend an extra copy of
178 # the library path with the suffix applied.
180 # Paths with LIBPATH_SUFFIX
181 lib_path1=
182 # Paths without LIBPATH_SUFFIX
183 lib_path2=
184 if [ "${LIB_PATH}" != ":" ] ; then
185 lib_path2=${LIB_PATH}
188 # Add args to lib_path1 and lib_path2, discarding any duplicates
189 append_to_lib_path()
191 if [ $# != 0 ]; then
192 for lib in "$@"; do
193 # The "=" is harmless if we aren't using a sysroot, but also needless.
194 if [ "x${use_sysroot}" = "xyes" ] ; then
195 lib="=${lib}"
197 skip_lib=no
198 for libpath_suffix in ${LIBPATH_SUFFIX}; do
199 case "${lib}" in
200 *${libpath_suffix})
201 case :${lib_path1}: in
202 *:${lib}:*) ;;
203 ::) lib_path1=${lib} ;;
204 *) lib_path1=${lib_path1}:${lib} ;;
205 esac ;;
207 if test -n "${LIBPATH_SUFFIX_SKIP}"; then
208 case "${lib}" in
209 *${LIBPATH_SUFFIX_SKIP}) skip_lib=yes ;;
210 esac
212 if test "${skip_lib}" = "no"; then
213 case :${lib_path1}: in
214 *:${lib}${libpath_suffix}:*) ;;
215 ::) lib_path1=${lib}${libpath_suffix} ;;
216 *) lib_path1=${lib_path1}:${lib}${libpath_suffix} ;;
217 esac
218 fi ;;
219 esac
220 done
221 if test "${skip_lib}" = "no"; then
222 case :${lib_path1}:${lib_path2}: in
223 *:${lib}:*) ;;
224 *::) lib_path2=${lib} ;;
225 *) lib_path2=${lib_path2}:${lib} ;;
226 esac
228 done
232 # Always search $(tooldir)/lib, aka /usr/local/TARGET/lib when native
233 # except when LIBPATH=":".
234 if [ "${LIB_PATH}" != ":" ] ; then
235 libs=
236 if [ "x${TOOL_LIB}" = "x" ] ; then
237 if [ "x${NATIVE}" = "xyes" ] ; then
238 libs="${exec_prefix}/${target_alias}/lib"
240 else
241 # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
242 # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} are in the default search path,
243 # because 64bit libraries may be in both places, depending on
244 # cross-development setup method (e.g.: /usr/s390x-linux/lib64
245 # vs. /usr/s390-linux/lib64)
246 for libpath_suffix in ${LIBPATH_SUFFIX}; do
247 case "${NATIVE}:${libpath_suffix}:${TOOL_LIB}" in
248 :* | *::* | *:*:*${libpath_suffix}) ;;
249 *) libs="${exec_prefix}/${target_alias}/lib${libpath_suffix}" ;;
250 esac
251 done
252 libs="${exec_prefix}/${TOOL_LIB}/lib ${libs}"
254 append_to_lib_path ${libs}
257 if [ "x${LIB_PATH}" = "x" ] && [ "x${USE_LIBPATH}" = xyes ] ; then
258 libs=${NATIVE_LIB_DIRS}
259 if [ "x${NATIVE}" = "xyes" ] ; then
260 case " ${libs} " in
261 *" ${libdir} "*) ;;
262 *) libs="${libdir} ${libs}" ;;
263 esac
265 append_to_lib_path ${libs}
268 case :${lib_path1}:${lib_path2}: in
269 *:: | ::*) LIB_PATH=${lib_path1}${lib_path2} ;;
270 *) LIB_PATH=${lib_path1}:${lib_path2} ;;
271 esac
273 LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
275 # We need it for testsuite.
276 set $EMULATION_LIBPATH
277 if [ "x$1" = "x$EMULATION_NAME" ]; then
278 test -d tmpdir || mkdir tmpdir
279 rm -f tmpdir/libpath.exp
280 echo "set libpath \"${LIB_PATH}\"" | sed -e 's/:/ /g' > tmpdir/libpath.exp
283 if [ "x$SCRIPT_NAME" = "xelf" ]; then
284 GENERATE_COMBRELOC_SCRIPT=yes
287 SEGMENT_SIZE=${SEGMENT_SIZE-${MAXPAGESIZE-${TARGET_PAGE_SIZE}}}
289 # Determine DATA_ALIGNMENT for the 5 variants, using
290 # values specified in the emulparams/<script_to_run>.sh file or default.
292 DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}"
293 DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}"
294 DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}"
295 DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}"
296 DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
298 LD_FLAG=r
299 DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
300 DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
301 ( echo "/* Script for -r */"
302 source_sh ${CUSTOMIZER_SCRIPT}
303 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
304 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xr
306 LD_FLAG=u
307 DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
308 CONSTRUCTING=" "
309 ( echo "/* Script for -Ur */"
310 source_sh ${CUSTOMIZER_SCRIPT}
311 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
312 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu
314 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
315 RELOCATING=" "
316 LD_FLAG=
317 ( echo "/* Default linker script, for normal executables */"
318 source_sh ${CUSTOMIZER_SCRIPT}
319 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
320 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.x
322 LD_FLAG=textonly
323 ( echo "/* Script for -z separate-code */"
324 source_sh ${CUSTOMIZER_SCRIPT}
325 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
326 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xe
328 if test -n "$GENERATE_RELRO_SCRIPT"; then
329 LD_FLAG=
330 RELRO=" "
331 ( echo "/* Script for -z relro */"
332 source_sh ${CUSTOMIZER_SCRIPT}
333 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
334 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xo
335 LD_FLAG=textonly
336 ( echo "/* Script for -z separate-code -z relro */"
337 source_sh ${CUSTOMIZER_SCRIPT}
338 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
339 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xeo
340 unset RELRO
342 LD_FLAG=n
343 DATA_ALIGNMENT=${DATA_ALIGNMENT_n}
344 ( echo "/* Script for -n */"
345 source_sh ${CUSTOMIZER_SCRIPT}
346 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
347 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xn
349 LD_FLAG=N
350 DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
351 ( echo "/* Script for -N */"
352 source_sh ${CUSTOMIZER_SCRIPT}
353 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
354 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xbn
356 if test -n "$GENERATE_COMBRELOC_SCRIPT"; then
357 DATA_ALIGNMENT=${DATA_ALIGNMENT_c-${DATA_ALIGNMENT_}}
358 LD_FLAG=c
359 COMBRELOC=ldscripts/${EMULATION_NAME}.xc.tmp
360 ( echo "/* Script for -z combreloc */"
361 source_sh ${CUSTOMIZER_SCRIPT}
362 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
363 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xc
364 rm -f ${COMBRELOC}
365 LD_FLAG=ctextonly
366 COMBRELOC=ldscripts/${EMULATION_NAME}.xce.tmp
367 ( echo "/* Script for -z combreloc -z separate-code */"
368 source_sh ${CUSTOMIZER_SCRIPT}
369 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
370 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xce
371 rm -f ${COMBRELOC}
372 RELRO_NOW=" "
373 LD_FLAG=w
374 COMBRELOC=ldscripts/${EMULATION_NAME}.xw.tmp
375 ( echo "/* Script for -z combreloc -z relro -z now */"
376 source_sh ${CUSTOMIZER_SCRIPT}
377 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
378 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xw
379 rm -f ${COMBRELOC}
380 LD_FLAG=wtextonly
381 COMBRELOC=ldscripts/${EMULATION_NAME}.xwe.tmp
382 ( echo "/* Script for -z combreloc -z separate-code -z relro -z now */"
383 source_sh ${CUSTOMIZER_SCRIPT}
384 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
385 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xwe
386 rm -f ${COMBRELOC}
387 COMBRELOC=
388 unset RELRO_NOW
389 if test -n "$GENERATE_RELRO_SCRIPT"; then
390 LD_FLAG=c
391 RELRO=" "
392 COMBRELOC=ldscripts/${EMULATION_NAME}.xco.tmp
393 ( echo "/* Script for -z combreloc -z relro */"
394 source_sh ${CUSTOMIZER_SCRIPT}
395 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
396 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xco
397 rm -f ${COMBRELOC}
398 LD_FLAG=ctextonly
399 COMBRELOC=ldscripts/${EMULATION_NAME}.xceo.tmp
400 ( echo "/* Script for -z combreloc -z separate-code -z relro */"
401 source_sh ${CUSTOMIZER_SCRIPT}
402 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
403 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xceo
404 rm -f ${COMBRELOC}
405 COMBRELOC=
406 unset RELRO
410 if test -n "$GENERATE_SHLIB_SCRIPT"; then
411 DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}}
412 CREATE_SHLIB=" "
413 LD_FLAG=shared
414 ( echo "/* Script for -shared */"
415 source_sh ${CUSTOMIZER_SCRIPT}
416 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
417 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xs
418 LD_FLAG=sharedtextonly
419 ( echo "/* Script for -shared -z separate-code */"
420 source_sh ${CUSTOMIZER_SCRIPT}
421 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
422 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xse
424 if test -n "$GENERATE_RELRO_SCRIPT"; then
425 RELRO=" "
426 LD_FLAG=shared
427 ( echo "/* Script for -shared -z relro */"
428 source_sh ${CUSTOMIZER_SCRIPT}
429 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
430 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xso
431 LD_FLAG=sharedtextonly
432 ( echo "/* Script for -shared -z separate-code -z relro */"
433 source_sh ${CUSTOMIZER_SCRIPT}
434 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
435 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xseo
436 unset RELRO
438 if test -n "$GENERATE_COMBRELOC_SCRIPT"; then
439 DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}}
440 LD_FLAG=cshared
441 COMBRELOC=ldscripts/${EMULATION_NAME}.xsc.tmp
442 ( echo "/* Script for -shared -z combreloc */"
443 source_sh ${CUSTOMIZER_SCRIPT}
444 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
445 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc
446 rm -f ${COMBRELOC}
447 LD_FLAG=csharedtextonly
448 COMBRELOC=ldscripts/${EMULATION_NAME}.xsce.tmp
449 ( echo "/* Script for -shared -z combreloc -z separate-code */"
450 source_sh ${CUSTOMIZER_SCRIPT}
451 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
452 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsce
453 rm -f ${COMBRELOC}
454 RELRO_NOW=" "
455 LD_FLAG=wshared
456 COMBRELOC=ldscripts/${EMULATION_NAME}.xsw.tmp
457 ( echo "/* Script for -shared -z combreloc -z relro -z now */"
458 source_sh ${CUSTOMIZER_SCRIPT}
459 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
460 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsw
461 rm -f ${COMBRELOC}
462 LD_FLAG=wsharedtextonly
463 COMBRELOC=ldscripts/${EMULATION_NAME}.xswe.tmp
464 ( echo "/* Script for -shared -z combreloc -z separate-code -z relro -z now */"
465 source_sh ${CUSTOMIZER_SCRIPT}
466 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
467 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xswe
468 rm -f ${COMBRELOC}
469 unset RELRO_NOW
471 if test -n "$GENERATE_RELRO_SCRIPT"; then
472 LD_FLAG=wshared
473 RELRO=" "
474 COMBRELOC=ldscripts/${EMULATION_NAME}.xsco.tmp
475 ( echo "/* Script for -shared -z combreloc -z relro */"
476 source_sh ${CUSTOMIZER_SCRIPT}
477 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
478 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsco
479 rm -f ${COMBRELOC}
480 LD_FLAG=wsharedtextonly
481 COMBRELOC=ldscripts/${EMULATION_NAME}.xsceo.tmp
482 ( echo "/* Script for -shared -z combreloc -z separate-code -z relro */"
483 source_sh ${CUSTOMIZER_SCRIPT}
484 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
485 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsceo
486 rm -f ${COMBRELOC}
487 unset RELRO
489 COMBRELOC=
491 unset CREATE_SHLIB
494 if test -n "$GENERATE_PIE_SCRIPT"; then
495 DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}}
496 CREATE_PIE=" "
497 LD_FLAG=pie
498 ( echo "/* Script for -pie */"
499 source_sh ${CUSTOMIZER_SCRIPT}
500 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
501 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xd
502 LD_FLAG=pietextonly
503 ( echo "/* Script for -pie -z separate-code */"
504 source_sh ${CUSTOMIZER_SCRIPT}
505 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
506 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xde
507 if test -n "$GENERATE_RELRO_SCRIPT"; then
508 RELRO=" "
509 LD_FLAG=pie
510 ( echo "/* Script for -pie -z relro */"
511 source_sh ${CUSTOMIZER_SCRIPT}
512 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
513 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdo
514 LD_FLAG=pietextonly
515 ( echo "/* Script for -pie -z separate-code -z relro */"
516 source_sh ${CUSTOMIZER_SCRIPT}
517 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
518 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdeo
519 unset RELRO
521 if test -n "$GENERATE_COMBRELOC_SCRIPT"; then
522 DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}}
523 COMBRELOC=ldscripts/${EMULATION_NAME}.xdc.tmp
524 LD_FLAG=cpie
525 ( echo "/* Script for -pie -z combreloc */"
526 source_sh ${CUSTOMIZER_SCRIPT}
527 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
528 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdc
529 rm -f ${COMBRELOC}
530 LD_FLAG=cpietextonly
531 COMBRELOC=ldscripts/${EMULATION_NAME}.xdce.tmp
532 ( echo "/* Script for -pie -z combreloc -z separate-code */"
533 source_sh ${CUSTOMIZER_SCRIPT}
534 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
535 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdce
536 rm -f ${COMBRELOC}
537 RELRO_NOW=" "
538 LD_FLAG=wpie
539 COMBRELOC=ldscripts/${EMULATION_NAME}.xdw.tmp
540 ( echo "/* Script for -pie -z combreloc -z relro -z now */"
541 source_sh ${CUSTOMIZER_SCRIPT}
542 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
543 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdw
544 rm -f ${COMBRELOC}
545 LD_FLAG=wpietextonly
546 COMBRELOC=ldscripts/${EMULATION_NAME}.xdwe.tmp
547 ( echo "/* Script for -pie -z combreloc -z separate-code -z relro -z now */"
548 source_sh ${CUSTOMIZER_SCRIPT}
549 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
550 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdwe
551 rm -f ${COMBRELOC}
552 unset RELRO_NOW
554 if test -n "$GENERATE_RELRO_SCRIPT"; then
555 LD_FLAG=wpie
556 RELRO=" "
557 COMBRELOC=ldscripts/${EMULATION_NAME}.xdco.tmp
558 ( echo "/* Script for -pie -z combreloc -z relro */"
559 source_sh ${CUSTOMIZER_SCRIPT}
560 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
561 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdco
562 rm -f ${COMBRELOC}
563 LD_FLAG=wpietextonly
564 COMBRELOC=ldscripts/${EMULATION_NAME}.xdceo.tmp
565 ( echo "/* Script for -pie -z combreloc -z separate-code -z relro */"
566 source_sh ${CUSTOMIZER_SCRIPT}
567 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
568 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdceo
569 rm -f ${COMBRELOC}
571 unset RELRO
573 COMBRELOC=
575 unset CREATE_PIE
578 if test -n "$GENERATE_AUTO_IMPORT_SCRIPT"; then
579 LD_FLAG=auto_import
580 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
581 ( echo "/* Script for --enable-auto-import */"
582 source_sh ${CUSTOMIZER_SCRIPT}
583 source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
584 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa
587 case "$COMPILE_IN: $EMULATION_LIBPATH " in
588 :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;;
589 esac
591 # PR ld/5652:
592 # Determine if the shell has support for the variable BASH_LINENO.
593 # When it is the case, it is only available inside functions.
594 has_lineno()
596 test "x$BASH_LINENO" != "x"
599 # Enable accruate error source in the compiler error messages, if possible.
600 if has_lineno; then
601 . ${srcdir}/genscrba.sh
602 else
603 source_em()
605 source_sh $1
607 fragment()
609 cat >> e${EMULATION_NAME}.c
613 # Generate e${EMULATION_NAME}.c.
614 # Start with an empty file, then the sourced .em script
615 # can use the "fragment" function to append.
616 > e${EMULATION_NAME}.c
617 source_em ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
619 if test -n "${DEPDIR}"; then
620 ecdeps=
621 for dep in `cat ${DEPDIR}/e${EMULATION_NAME}.Tc`; do
622 case " $ecdeps " in
623 *" $dep "*): ;;
624 *) ecdeps="$ecdeps $dep" ;;
625 esac
626 done
627 rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
628 echo "e${EMULATION_NAME}.c:${ecdeps}" > ${DEPDIR}/e${EMULATION_NAME}.Pc