1# configure.tgt
2#
3#   Copyright (C) 2013-2024 Free Software Foundation, Inc.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; see the file COPYING3.  If not see
17# <http://www.gnu.org/licenses/>.
18
19# This is the linker target specific file.  This is invoked by the
20# autoconf generated configure script.  Putting it in a separate shell
21# file lets us skip running autoconf when modifying target specific
22# information.
23
24# This file switches on the shell variable ${targ}, and sets the
25# following shell variables:
26#  targ_emul		name of linker emulation to use
27#  targ_extra_emuls	additional linker emulations to provide
28#  targ_extra_libpath	additional linker emulations using LIB_PATH
29#  targ_extra_ofiles	additional host-compiled objects needed by the emulation
30#  targ64_extra_emuls	additional linker emulations to provide if
31#			--enable-64-bit-bfd is given or if host is 64 bit.
32#  targ64_extra_libpath	additional linker emulations using LIB_PATH if
33#			--enable-64-bit-bfd is given or if host is 64 bit.
34#  NATIVE_LIB_DIRS	library directories to search on this host
35#			(if we are a native or sysrooted linker)
36
37targ_extra_emuls=
38targ_extra_libpath=
39targ_extra_ofiles="ldelf.o ldelfgen.o"
40targ64_extra_emuls=
41targ64_extra_libpath=
42
43# By default the linker will generate warnings if it is creating an
44# executable stack or a segment with all three of read, write and
45# execute permissions.  These settings are not appropriate for all
46# targets however, so we can change them here:
47
48if test "${ac_default_ld_warn_rwx_segments}" = unset; then
49  case "${targ}" in
50      # The CRIS and V850 default linker scripts yields just one segment
51      # as intended, so a rwx segment warning is not helpful.
52      # The HPPA's and SPARC's PLT sections use a constructed trampoline
53      # hence it needs to have a RWX segment.
54      # Many MIPS targets use executable segments.
55    cris-*-* | crisv32-*-* | \
56    hppa*-*-* | \
57    mips*-*-* | \
58    microblaze*-*-* | \
59    sparc*-*-* | \
60    v850*-*-*)
61      ac_default_ld_warn_rwx_segments=0
62      ;;
63    *)
64      ;;
65  esac
66fi
67
68if test "${ac_default_ld_warn_execstack}" = 2; then
69  case "${targ}" in
70      # The HPPA port needs to support older kernels that
71      # use executable stacks for signals and syscalls.
72      # Many MIPS targets use executable stacks.
73    hppa*-*-* | \
74    mips*-*-*)
75      ac_default_ld_warn_execstack=0
76      ;;
77    *)
78      ;;
79  esac
80fi
81
82# Please try to keep this table more or less in alphabetic order - it
83# makes it much easier to lookup a specific archictecture.
84case "${targ}" in
85aarch64_be-*-netbsd*)	targ_emul=aarch64nbsdb
86			targ_extra_emuls="aarch64nbsd aarch64elfb aarch64elf armelfb_nbsd_eabihf armelf_nbsd_eabihf armelfb_nbsd_eabi armelf_nbsd_eabi armelfb_nbsd armelf_nbsd armelf armelfb"
87			;;
88aarch64_be-*-elf)	targ_emul=aarch64elfb
89			targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b armelfb armelf"
90			;;
91aarch64-*-netbsd*)	targ_emul=aarch64nbsd
92			targ_extra_emuls="aarch64nbsdb aarch64elf aarch64elfb armelf_nbsd_eabihf armelfb_nbsd_eabihf armelf_nbsd_eabi armelfb_nbsd_eabi armelf_nbsd armelfb_nbsd armelf armelfb"
93			;;
94aarch64-*-elf | aarch64-*-rtems* | aarch64-*-genode*)
95			targ_emul=aarch64elf
96			targ_extra_emuls="aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb"
97			;;
98aarch64-*-cloudabi*)	targ_emul=aarch64cloudabi
99			targ_extra_emuls=aarch64cloudabib
100			;;
101aarch64-*-freebsd*)	targ_emul=aarch64fbsd
102			targ_extra_emuls="aarch64fbsdb aarch64elf"
103			;;
104aarch64-*-fuchsia*)	targ_emul=aarch64elf
105			targ_extra_emuls="aarch64elfb armelf armelfb"
106			;;
107aarch64_be-*-linux-gnu_ilp32)
108			targ_emul=aarch64linux32b
109			targ_extra_libpath="aarch64linuxb aarch64linux aarch64linux32 armelfb_linux_eabi armelf_linux_eabi"
110			targ_extra_emuls="aarch64elfb aarch64elf aarch64elf32 aarch64elf32b armelfb armelf $targ_extra_libpath"
111			;;
112aarch64-*-linux-gnu_ilp32)
113			targ_emul=aarch64linux32
114			targ_extra_libpath="aarch64linux aarch64linuxb aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
115			targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb $targ_extra_libpath"
116			;;
117aarch64_be-*-linux*)	targ_emul=aarch64linuxb
118			targ_extra_libpath="aarch64linux aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
119			targ_extra_emuls="aarch64elfb aarch64elf aarch64elf32 aarch64elf32b armelfb armelf $targ_extra_libpath"
120			;;
121aarch64-*-linux*)	targ_emul=aarch64linux
122			targ_extra_libpath="aarch64linuxb aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
123			targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb $targ_extra_libpath"
124			;;
125# This has to come after aarch64-*-linux* for aarch64-*-linux-gnu to hit the Linux branch.
126aarch64-*-gnu*)
127			targ_emul=aarch64gnu
128			targ_extra_emuls="aarch64elf aarch64elfb armelf armelfb"
129			;;
130aarch64-*-haiku*)	targ_emul=aarch64haiku
131			targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb armelf_haiku $targ_extra_libpath"
132			;;
133aarch64-*-nto*)		targ_emul=aarch64nto
134			targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb"
135			;;
136aarch64-*-pe* | aarch64-*-mingw*)
137			targ_emul=aarch64pe
138			targ_extra_emuls="arm64pe"
139			targ_extra_ofiles="deffilep.o pep-dll-aarch64.o pe-dll.o pdb.o"
140			;;
141alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
142			targ_emul=elf64alpha_fbsd
143			targ_extra_emuls="elf64alpha alpha"
144			tdir_alpha=`echo ${targ_alias} | sed -e 's/freebsd/freebsdecoff/'`
145			;;
146alpha*-*-linux*ecoff*)	targ_emul=alpha
147			targ_extra_emuls=elf64alpha
148			tdir_elf64alpha=`echo ${targ_alias} | sed -e 's/ecoff//'`
149			;;
150alpha*-*-linux-*)	targ_emul=elf64alpha
151			targ_extra_emuls=alpha
152			tdir_alpha=`echo ${targ_alias} | sed -e 's/linux\(-gnu\)*/linux\1ecoff/'`
153			;;
154alpha*-*-osf*)		targ_emul=alpha
155			targ_extra_ofiles=
156			;;
157alpha*-*-gnu*)		targ_emul=elf64alpha
158			;;
159alpha*-*-netbsd*)	targ_emul=elf64alpha_nbsd
160			;;
161alpha*-*-openbsd*)	targ_emul=elf64alpha
162			;;
163alpha*-*-*vms*)		targ_emul=alphavms
164			targ_extra_ofiles=
165			;;
166am33_2.0-*-linux*)	targ_emul=elf32am33lin # mn10300 variant
167			;;
168arc*-*-elf*)		targ_emul=arcelf
169			targ_extra_emuls="arclinux arclinux_nps arcv2elf arcv2elfx"
170			;;
171arc*-*-linux*)		case "${with_cpu}" in
172			nps400)	targ_emul=arclinux_nps
173				targ_extra_emuls=arclinux
174				;;
175			*)	targ_emul=arclinux
176				targ_extra_emuls=arclinux_nps
177				;;
178			esac
179			targ_extra_emuls="${targ_extra_emuls} arcelf arcv2elf arcv2elfx"
180			;;
181arm*-*-cegcc*)		targ_emul=arm_wince_pe
182			targ_extra_ofiles="deffilep.o pe-dll.o"
183			LIB_PATH='${tooldir}/lib/w32api'
184			;;
185arm-wince-pe | arm-*-wince | arm*-*-mingw32ce*)
186			targ_emul=arm_wince_pe
187			targ_extra_ofiles="deffilep.o pe-dll.o"
188			;;
189arm-*-pe)		targ_emul=armpe
190			targ_extra_ofiles="deffilep.o pe-dll.o"
191			;;
192arm*b-*-freebsd*)	targ_emul=armelfb_fbsd
193			targ_extra_emuls="armelf_fbsd armelf"
194			;;
195arm*-*-freebsd* | arm-*-kfreebsd*-gnu)
196			targ_emul=armelf_fbsd
197			targ_extra_emuls="armelfb_fbsd armelf"
198			;;
199arm*eb-*-netbsd*-*eabihf*)
200			targ_emul=armelfb_nbsd_eabihf
201			targ_extra_emuls="armelf_nbsd_eabihf armelf_nbsd_eabi armelfb_nbsd_eabi armelf_nbsd armelfb_nbsd armelf"
202			;;
203arm*eb-*-netbsd*-*eabi*)
204			targ_emul=armelfb_nbsd_eabi
205			targ_extra_emuls="armelf_nbsd_eabi armelf_nbsd_eabihf armelfb_nbsd_eabihf armelf_nbsd armelfb_nbsd armelf"
206			;;
207arm*-*-netbsd*-*eabihf*)
208			targ_emul=armelf_nbsd_eabihf
209			targ_extra_emuls="armelfb_nbsd_eabihf armelf_nbsd_eabi armelfb_nbsd_eabi armelf_nbsd armelfb_nbsd armelf"
210			;;
211arm*-*-netbsd*-*eabi*)
212			targ_emul=armelf_nbsd_eabi
213			targ_extra_emuls="armelfb_nbsd_eabi armelf_nbsd_eabihf armelfb_nbsd_eabihf armelf_nbsd armelfb_nbsd armelf"
214			;;
215arm*eb-*-netbsd*)	targ_emul=armelfb_nbsd
216			targ_extra_emuls="armelf_nbsd armelf"
217			;;
218arm*-*-netbsd*)		targ_emul=armelf_nbsd
219 			targ_extra_emuls="armelfb_nbsd armelf"
220 			;;
221arm-*-nto*)		targ_emul=armnto
222			;;
223arm-*-phoenix*)		targ_emul=armelf
224			;;
225armeb-*-elf | armeb-*-eabi*)
226			targ_emul=armelfb
227			;;
228arm-*-elf | arm*-*-eabi* | arm-*-rtems* | arm-*-genode*)
229			targ_emul=armelf
230			;;
231arm-*-kaos*)		targ_emul=armelf
232			;;
233arm9e-*-elf)		targ_emul=armelf
234			;;
235arm*b-*-linux-*eabi*)	targ_emul=armelfb_linux_eabi
236			targ_extra_emuls=armelf_linux_eabi
237			targ_extra_libpath=$targ_extra_emuls
238			;;
239arm*b-*-linux-*)	targ_emul=armelfb_linux
240			targ_extra_emuls="armelfb armelf armelf_linux"
241			targ_extra_libpath="armelf_linux"
242			;;
243arm*-*-linux-*eabi*)	targ_emul=armelf_linux_eabi
244			targ_extra_emuls="armelfb_linux_eabi"
245			targ_extra_libpath=$targ_extra_emuls
246			;;
247arm*-*-uclinuxfdpiceabi)
248			targ_emul=armelf_linux_eabi
249			targ_extra_emuls="armelfb_linux_eabi armelf_linux_fdpiceabi armelfb_linux_fdpiceabi"
250			targ_extra_libpath=$targ_extra_emuls
251			;;
252arm*-*-linux-*)		targ_emul=armelf_linux
253			targ_extra_emuls="armelf armelfb armelfb_linux"
254			targ_extra_libpath="armelfb_linux"
255			;;
256arm*b-*-nacl*)		targ_emul=armelfb_nacl
257			targ_extra_emuls="armelf_nacl"
258			targ_extra_libpath=$targ_extra_emuls
259			;;
260arm*-*-nacl*)		targ_emul=armelf_nacl
261			targ_extra_emuls="armelfb_nacl"
262			targ_extra_libpath=$targ_extra_emuls
263			;;
264arm*-*-uclinux*eabi*)	targ_emul=armelf_linux_eabi
265			targ_extra_emuls=armelfb_linux_eabi
266			targ_extra_libpath=$targ_extra_emuls
267			;;
268arm*-*-uclinux*)	targ_emul=armelf_linux
269			targ_extra_emuls="armelf armelfb armelfb_linux"
270			targ_extra_libpath="armelfb_linux"
271			;;
272arm-*-vxworks)		targ_emul=armelf_vxworks
273			;;
274arm*-*-conix*)		targ_emul=armelf
275			;;
276arm*-*-fuchsia*)	targ_emul=armelf_fuchsia
277			targ_extra_emuls="armelfb_fuchsia armelf armelfb"
278			;;
279arm*-*-haiku*)		targ_emul=armelf_haiku
280			targ_extra_emuls=armelf
281			;;
282avr-*-*)		targ_emul=avr2
283			targ_extra_emuls="avr1 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega1 avrxmega2 avrxmega2_flmap avrxmega3 avrxmega4 avrxmega4_flmap avrxmega5 avrxmega6 avrxmega7 avrtiny"
284			;;
285bfin-*-elf | bfin-*-rtems*)
286			targ_emul=elf32bfin
287			targ_extra_emuls="elf32bfinfd"
288			targ_extra_libpath=$targ_extra_emuls
289			;;
290bfin-*-uclinux*)	targ_emul=elf32bfin;
291			targ_extra_emuls="elf32bfinfd"
292			targ_extra_libpath=$targ_extra_emuls
293			;;
294bfin-*-linux-uclibc*)	targ_emul=elf32bfinfd;
295			targ_extra_emuls="elf32bfin"
296			targ_extra_libpath=$targ_extra_emuls
297			;;
298bpf-*-*)		targ_emul=elf64bpf
299			;;
300cr16-*-elf*)		targ_emul=elf32cr16
301			;;
302cris-*-*aout*)		targ_emul=crisaout
303			targ_extra_emuls="criself crislinux"
304			targ_extra_libpath=$targ_extra_emuls
305			;;
306cris-*-linux-* | crisv32-*-linux-*)
307			targ_emul=crislinux
308			;;
309cris-*-* | crisv32-*-*)	targ_emul=criself
310			targ_extra_emuls="crisaout crislinux"
311			targ_extra_libpath=$targ_extra_emuls
312			;;
313crx-*-elf*)		targ_emul=elf32crx
314			;;
315
316csky-*-elf*)		targ_emul=cskyelf
317			;;
318csky-*-linux*)		targ_emul=cskyelf_linux
319			;;
320
321d10v-*-*)		targ_emul=d10velf
322			;;
323d30v-*-*ext*)		targ_emul=d30v_e
324			targ_extra_emuls="d30velf d30v_o"
325			targ_extra_ofiles=ldelfgen.o
326			;;
327d30v-*-*onchip*)	targ_emul=d30v_o
328			targ_extra_emuls="d30velf d30v_e"
329			targ_extra_ofiles=ldelfgen.o
330			;;
331d30v-*-*)		targ_emul=d30velf
332			targ_extra_emuls="d30v_e d30v_o"
333			targ_extra_ofiles=ldelfgen.o
334			;;
335dlx-*-elf*)		targ_emul=elf32_dlx
336			targ_extra_ofiles=ldelfgen.o
337			;;
338epiphany-*-*)		targ_emul=elf32epiphany
339			targ_extra_emuls="elf32epiphany_4x4"
340			;;
341fido*-*-elf*)		targ_emul=m68kelf
342			;;
343fr30-*-*)		targ_emul=elf32fr30
344			targ_extra_ofiles=ldelfgen.o
345			;;
346frv-*-*linux*)		targ_emul=elf32frvfd
347			;;
348frv-*-*)		targ_emul=elf32frv
349			targ_extra_emuls="elf32frvfd"
350			;;
351ft32-*-*)		targ_emul=elf32ft32
352			targ_extra_ofiles=ldelfgen.o
353			;;
354h8300-*-elf* | h8300-*-rtems*)
355			targ_emul=h8300elf;
356			targ_extra_emuls="h8300helf h8300self h8300hnelf h8300snelf h8300sxelf h8300sxnelf"
357			;;
358h8300-*-linux*)
359			targ_emul=h8300elf_linux;
360			targ_extra_emuls="h8300helf_linux h8300self_linux h8300sxelf_linux"
361			;;
362hppa*64*-*-linux-*)	targ_emul=hppa64linux
363			;;
364hppa*64*-hpux*)		targ_emul=elf64hppa
365			;;
366hppa*-*-linux-*)	targ_emul=hppalinux
367			;;
368hppa*-*-*elf*)		targ_emul=hppaelf
369			;;
370hppa*-*-lites*)		targ_emul=hppaelf
371			;;
372hppa*-*-netbsd*)	targ_emul=hppanbsd
373			;;
374hppa*-*-openbsd*)	targ_emul=hppaobsd
375			;;
376i[3-7]86-*-nto-qnx*)	targ_emul=i386nto
377			;;
378i[3-7]86-*-go32)	targ_emul=i386go32
379			targ_extra_ofiles=
380			;;
381i[3-7]86-*-msdosdjgpp*) targ_emul=i386go32
382			targ_extra_ofiles=
383			;;
384i[3-7]86-*-lynxos*)	targ_emul=i386lynx
385			;;
386i[3-7]86-*-aros*)	targ_emul=elf_i386
387			targ_extra_emuls=elf_iamcu
388			;;
389i[3-7]86-*-rdos*)	targ_emul=elf_i386
390			targ_extra_emuls=elf_iamcu
391			;;
392i[3-7]86-*-bsd)		targ_emul=i386bsd
393			targ_extra_ofiles=
394			;;
395i[3-7]86-*-bsd386)	targ_emul=i386bsd
396			targ_extra_ofiles=
397			;;
398i[3-7]86-*-bsdi*)	targ_emul=i386bsd
399			targ_extra_ofiles=
400			;;
401i[3-7]86-*-linux-*)	targ_emul=elf_i386
402			targ_extra_emuls="elf_iamcu"
403			targ64_extra_emuls="elf_x86_64 elf32_x86_64"
404			targ64_extra_libpath="elf_x86_64 elf32_x86_64"
405			;;
406i[3-7]86-*-redox*)	targ_emul=elf_i386
407			targ_extra_emuls=elf_x86_64
408			;;
409i[3-7]86-*-solaris2*)	targ_emul=elf_i386_sol2
410			targ_extra_emuls="elf_i386_ldso elf_i386 elf_iamcu elf_x86_64_sol2 elf_x86_64"
411			targ_extra_libpath=$targ_extra_emuls
412			;;
413i[3-7]86-*-solaris*)	targ_emul=elf_i386_ldso
414			targ_extra_emuls="elf_i386"
415			targ_extra_libpath=$targ_extra_emuls
416			;;
417i[3-7]86-*-netbsd* | \
418i[3-7]86-*-netbsd*-gnu* | \
419i[3-7]86-*-knetbsd*-gnu | \
420i[3-7]86-*-openbsd*)
421			targ_emul=elf_i386
422			targ_extra_emuls="elf_iamcu"
423			;;
424i[3-7]86-*-elfiamcu)	targ_emul=elf_iamcu
425			targ_extra_emuls=elf_i386
426			;;
427i[3-7]86-*-elf* | i[3-7]86-*-rtems* | i[3-7]86-*-genode*)
428			targ_emul=elf_i386
429			targ_extra_emuls=elf_iamcu
430			;;
431i[3-7]86-*-dragonfly*)	targ_emul=elf_i386
432			targ_extra_emuls="elf_iamcu i386bsd"
433			;;
434i[3-7]86-*-freebsd* | i[3-7]86-*-kfreebsd*-gnu)
435			targ_emul=elf_i386_fbsd
436			targ_extra_emuls="elf_i386 elf_iamcu i386bsd"
437			;;
438i[3-7]86-*-gnu*)	targ_emul=elf_i386
439			targ_extra_emuls=elf_iamcu
440			;;
441i[3-7]86-*-msdos*)	targ_emul=i386msdos
442			targ_extra_emuls=i386aout
443			targ_extra_ofiles=
444			;;
445i[3-7]86-*-moss*)	targ_emul=i386moss
446			targ_extra_emuls=i386msdos
447			;;
448i[3-7]86-*-winnt*)	targ_emul=i386pe ;
449			targ_extra_ofiles="deffilep.o pdb.o pe-dll.o"
450			;;
451i[3-7]86-*-pe)		targ_emul=i386pe ;
452			targ_extra_ofiles="deffilep.o pdb.o pe-dll.o"
453			;;
454i[3-7]86-*-cygwin*)	targ_emul=i386pe ;
455			targ_extra_ofiles="deffilep.o pdb.o pe-dll.o" ;
456			test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api'
457			;;
458i[3-7]86-*-mingw32*)	targ_emul=i386pe ;
459			targ_extra_ofiles="deffilep.o pdb.o pe-dll.o"
460			;;
461i[3-7]86-*-interix*)	targ_emul=i386pe_posix;
462			targ_extra_ofiles="deffilep.o pe-dll.o"
463			;;
464i[3-7]86-*-beospe*)	targ_emul=i386beos
465			targ_extra_ofiles=
466			;;
467i[3-7]86-*-beos*)	targ_emul=elf_i386_be
468			;;
469i[3-7]86-*-haiku*)	targ_emul=elf_i386_haiku
470			;;
471i[3-7]86-*-vxworks*)	targ_emul=elf_i386_vxworks
472			;;
473i[3-7]86-*-chaos)	targ_emul=elf_i386_chaos
474			;;
475ia16-*-elf*)		targ_emul=elf_i386
476			targ_extra_emuls=i386msdos
477			;;
478ia64-*-elf*)		targ_emul=elf64_ia64
479			;;
480ia64-*-freebsd* | ia64-*-kfreebsd*-gnu)
481			targ_emul=elf64_ia64_fbsd
482			targ_extra_emuls="elf64_ia64"
483			;;
484ia64-*-netbsd*)		targ_emul=elf64_ia64
485			;;
486ia64-*-linux*)		targ_emul=elf64_ia64
487			;;
488ia64-*-*vms*)		targ_emul=elf64_ia64_vms
489			targ_extra_ofiles=ldelfgen.o
490			;;
491ia64-*-aix*)		targ_emul=elf64_aix
492			;;
493ip2k-*-elf)		targ_emul=elf32ip2k
494			;;
495iq2000-*-elf)		targ_emul=elf32iq2000
496			targ_extra_emuls="elf32iq10"
497			targ_extra_ofiles=ldelfgen.o
498			;;
499lm32-*-*linux*)		targ_emul=elf32lm32fd
500			;;
501lm32-*-*)		targ_emul=elf32lm32
502			targ_extra_emuls="elf32lm32fd"
503			;;
504kvx-*-linux*)		targ_emul=elf64kvx_linux
505			targ_extra_emuls="elf64kvx"
506			;;
507kvx-*-*)		targ_emul=elf64kvx;
508			targ_extra_emuls="elf64kvx_linux elf32kvx"
509			;;
510m32c-*-elf)
511			targ_emul=elf32m32c
512			;;
513m32r*le-*-elf*)		targ_emul=m32rlelf
514			;;
515m32r*-*-elf*)
516			targ_emul=m32relf
517			;;
518m32r*le-*-linux-*)	targ_emul=m32rlelf_linux
519			;;
520m32r*-*-linux-*)	targ_emul=m32relf_linux
521			;;
522m68hc11-*-*|m6811-*-*)	targ_emul=m68hc11elf
523			targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb"
524			;;
525m68hc12-*-*|m6812-*-*)	targ_emul=m68hc12elf
526			targ_extra_emuls="m68hc12elfb m68hc11elf m68hc11elfb"
527			;;
528m68*-*-netbsd*)	targ_emul=m68kelfnbsd
529			;;
530m68*-*-haiku*)		targ_emul=m68kelf
531			;;
532m68*-*-*)		targ_emul=m68kelf
533			;;
534mcore-*-pe)		targ_emul=mcorepe ;
535			targ_extra_ofiles="deffilep.o pe-dll.o"
536			;;
537mcore-*-elf)		targ_emul=elf32mcore
538			;;
539mep-*-elf)		targ_emul=elf32mep
540			;;
541metag-*-*)		targ_emul=elf32metag
542			;;
543microblazeel*-linux*)	targ_emul="elf32mbel_linux"
544			targ_extra_emuls="elf32mb_linux"
545			;;
546microblaze*-linux*)	targ_emul="elf32mb_linux"
547			targ_extra_emuls="elf32mbel_linux"
548			;;
549microblazeel*)		targ_emul=elf32microblazeel
550			targ_extra_emuls=elf32microblaze
551			;;
552microblaze*)		targ_emul=elf32microblaze
553			targ_extra_emuls=elf32microblazeel
554			;;
555mips*-sgi-irix5*)	targ_emul=elf32bsmip
556			;;
557mips*-sgi-irix6*)	targ_emul=elf32bmipn32
558			targ_extra_emuls="elf32bsmip elf64bmip"
559			targ_extra_libpath=$targ_extra_emuls
560			;;
561mips*el-*-haiku*)	targ_emul=elf_mipsel_haiku
562			targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
563			;;
564mips64*el-*-netbsd*)	targ_emul=elf32ltsmipn32 	 
565			targ_extra_emuls="elf64btsmip elf64ltsmip elf32ltsmip elf32btsmipn32 elf32btsmip" 	 
566			targ_extra_libpath=$targ_extra_emuls
567			;;
568mips64*-*-netbsd*)	targ_emul=elf32btsmipn32
569			targ_extra_emuls="elf64ltsmip elf64btsmip elf32btsmip elf32ltsmipn32 elf32ltsmip"
570			targ_extra_libpath=$targ_extra_emuls
571			;;
572mipsn64*el-*-netbsd*)	targ_emul=elf64ltsmip
573			targ_extra_emuls="elf64btsmip elf32ltsmip elf32btsmip elf32btsmipn32 elf32ltsmipn32"
574			targ_extra_libpath=$targ_extra_emuls
575			;; 	 
576mipsn64*-*-netbsd*)	targ_emul=elf64btsmip
577			targ_extra_emuls="elf64ltsmip elf64btsmip elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32"
578			targ_extra_libpath=$targ_extra_emuls
579  			;;
580mips*el-*-netbsd*)	targ_emul=elf32ltsmip
581			targ_extra_emuls="elf32btsmip elf64ltsmip elf64btsmip"
582			;;
583mips*-*-netbsd*)	targ_emul=elf32btsmip
584			targ_extra_emuls="elf32ltsmip elf64btsmip elf64ltsmip"
585			;;
586mips64el-*-openbsd*)	targ_emul=elf64ltsmip
587			targ_extra_emuls=elf64btsmip
588			;;
589mips64-*-openbsd*)	targ_emul=elf64btsmip
590			targ_extra_emuls=elf64ltsmip
591			;;
592mips*vr4300el-*-elf*)	targ_emul=elf32l4300
593			;;
594mips*vr4300-*-elf*)	targ_emul=elf32b4300
595			;;
596mips*vr4100el-*-elf*)	targ_emul=elf32l4300
597			;;
598mips*vr4100-*-elf*)	targ_emul=elf32b4300
599			;;
600mips*vr5000el-*-elf*)	targ_emul=elf32l4300
601			;;
602mips*vr5000-*-elf*)	targ_emul=elf32b4300
603			;;
604mips*el-sde-elf* | mips*el-mti-elf* | mips*el-img-elf*)
605			targ_emul=elf32ltsmip
606			targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
607			;;
608mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
609			targ_emul=elf32btsmip
610			targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
611			;;
612mips64*el-ps2-elf*)	targ_emul=elf32lr5900n32
613			targ_extra_emuls="elf32lr5900"
614			targ_extra_libpath=$targ_extra_emuls
615			;;
616mips*el-ps2-elf*)	targ_emul=elf32lr5900
617			targ_extra_emuls="elf32lr5900n32"
618			targ_extra_libpath=$targ_extra_emuls
619			;;
620mips*el-*-elf*)		targ_emul=elf32elmip
621			;;
622mips*-*-elf* | mips*-*-rtems*)
623			targ_emul=elf32ebmip
624			;;
625mips*el-*-vxworks*)	targ_emul=elf32elmipvxworks
626			targ_extra_emuls="elf32ebmipvxworks"
627			;;
628mips*-*-vxworks*)	targ_emul=elf32ebmipvxworks
629			targ_extra_emuls="elf32elmipvxworks"
630			;;
631mips*-*-windiss)	targ_emul=elf32mipswindiss
632			;;
633mips64*el-*-linux-gnuabi64)
634			targ_emul=elf64ltsmip
635			targ_extra_emuls="elf64btsmip elf32ltsmipn32 elf32btsmipn32 elf32ltsmip elf32btsmip"
636			targ_extra_libpath=$targ_extra_emuls
637			;;
638mips64*el-*-linux-*)	targ_emul=elf32ltsmipn32
639			targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
640			targ_extra_libpath=$targ_extra_emuls
641			;;
642mips64*-*-linux-gnuabi64)
643			targ_emul=elf64btsmip
644			targ_extra_emuls="elf64ltsmip elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip"
645			targ_extra_libpath=$targ_extra_emuls
646			;;
647mips64*-*-linux-*)	targ_emul=elf32btsmipn32
648			targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
649			targ_extra_libpath=$targ_extra_emuls
650			;;
651mips*el-*-linux-*)	targ_emul=elf32ltsmip
652			targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
653			targ_extra_libpath=$targ_extra_emuls
654			;;
655mips*-*-linux-*)	targ_emul=elf32btsmip
656			targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
657			targ_extra_libpath=$targ_extra_emuls
658			;;
659mips64*el-*-freebsd* | mips64*el-*-kfreebsd*-gnu)
660			targ_emul=elf32ltsmipn32_fbsd
661			targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmip_fbsd elf32btsmip_fbsd elf32btsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
662			targ_extra_libpath=$targ_extra_emuls
663			;;
664mips64*-*-freebsd* | mips64*-*-kfreebsd*-gnu)
665			targ_emul=elf32btsmipn32_fbsd
666			targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmip_fbsd elf32btsmip_fbsd elf32ltsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
667			targ_extra_libpath=$targ_extra_emuls
668			;;
669mips*el-*-freebsd* | mips*el-*-kfreebsd*-gnu)
670			targ_emul=elf32ltsmip_fbsd
671			targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmipn32_fbsd elf32btsmip_fbsd elf32btsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
672			targ_extra_libpath=$targ_extra_emuls
673			;;
674mips*-*-freebsd* | mips*-*-kfreebsd*-gnu)
675			targ_emul=elf32btsmip_fbsd
676			targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmip_fbsd elf32btsmipn32_fbsd elf32ltsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
677			targ_extra_libpath=$targ_extra_emuls
678			;;
679mips*-*-sysv4*)		targ_emul=elf32btsmip
680			;;
681mmix-*-*)		targ_emul=mmo
682			targ_extra_emuls=elf64mmix
683			;;
684mn10200-*-*)		targ_emul=mn10200
685			targ_extra_ofiles=ldelfgen.o
686			;;
687mn10300-*-*)		targ_emul=mn10300
688			;;
689moxie-*-moxiebox*)	targ_emul=moxiebox
690			targ_extra_ofiles=ldelfgen.o
691			;;
692moxie-*-*)		targ_emul=elf32moxie
693			;;
694msp430-*-*)		targ_emul=msp430elf
695			targ_extra_emuls="msp430X"
696			targ_extra_ofiles=ldelfgen.o
697			;;
698mt-*elf)		targ_emul=elf32mt
699			targ_extra_ofiles=ldelfgen.o
700			;;
701nds32*le-*-elf*)	targ_emul=nds32elf
702			targ_extra_emuls="nds32elf16m nds32belf nds32belf16m"
703			;;
704nds32*be-*-elf*)	targ_emul=nds32belf
705			targ_extra_emuls="nds32elf nds32elf16m nds32belf16m"
706			;;
707nds32*le-*-linux-gnu*)	targ_emul=nds32elf_linux
708			;;
709nds32*be-*-linux-gnu*)	targ_emul=nds32belf_linux
710			;;
711nios2*-*-linux*)	targ_emul=nios2linux
712			;;
713nios2*-*-*)		targ_emul=nios2elf
714			;;
715ns32k-pc532-mach* | ns32k-pc532-ux*)  targ_emul=pc532macha
716			targ_extra_ofiles=
717			;;
718ns32k-*-*bsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd
719			targ_extra_ofiles=
720			;;
721or1k-*-elf | or1knd-*-elf | or1k-*-rtems* | or1knd-*-rtems*)
722			targ_emul=elf32or1k
723			;;
724or1k-*-netbsd* | or1knd-*-netbsd*)	targ_emul=elf32or1k_nbsd
725			;;
726or1k-*-linux* | or1knd-*-linux*)	targ_emul=elf32or1k_linux
727			;;
728powerpc-*-netbsd*)
729			targ_emul=elf32ppc_nbsd
730			targ_extra_emuls="elf32ppc elf32ppcsim"
731			targ_extra_libpath=elf32ppc;
732			tdir_elf32ppcsim=`echo ${targ_alias} | sed -e 's/ppc/ppcsim/'`
733			targ64_extra_emuls=elf64ppc
734			targ64_extra_libpath=elf64ppc
735			;;
736powerpc64-*-netbsd*)
737			targ_emul=elf64ppc
738			targ_extra_emuls="elf32ppc elf32ppc_nbsd elf32ppcsim"
739			targ_extra_libpath="elf32ppc_nbsd elf32ppc"
740			tdir_elf32ppc=`echo "${targ_alias}" | sed -e 's/64//'`
741			tdir_elf32ppc_fbsd=$tdir_elf32ppc
742			;;
743pdp11-*-*)		targ_emul=pdp11
744			targ_extra_ofiles=
745			;;
746pjl*-*-*)		targ_emul=pjlelf
747			targ_extra_emuls="elf_i386 elf_iamcu"
748			;;
749pj*-*-*)		targ_emul=pjelf
750			targ_extra_ofiles=ldelfgen.o
751			;;
752powerpc-*-freebsd* | powerpc-*-kfreebsd*-gnu)
753			targ_emul=elf32ppc_fbsd
754			targ_extra_emuls="elf32ppc elf32ppcsim"
755			targ_extra_libpath=elf32ppc;
756			tdir_elf32ppcsim=`echo ${targ_alias} | sed -e 's/ppc/ppcsim/'`
757			;;
758powerpc64-*-freebsd*)
759			targ_emul=elf64ppc_fbsd
760			targ_extra_emuls="elf64ppc elf32ppc_fbsd elf32ppc"
761			targ_extra_libpath="elf32ppc_fbsd elf32ppc"
762			tdir_elf32ppc=`echo "${targ_alias}" | sed -e 's/64//'`
763			tdir_elf32ppc_fbsd=$tdir_elf32ppc
764			;;
765powerpc64le-*-freebsd*)
766			targ_emul=elf64lppc_fbsd
767			targ_extra_emuls="elf64lppc"
768			;;
769powerpc-*-vxworks*)
770			targ_emul=elf32ppcvxworks
771			targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim"
772			;;
773powerpc*-*-elf* | powerpc*-*-eabi* | powerpc*-*-sysv* \
774  | powerpc*-*-linux* | powerpc*-*-netbsd* | powerpc*-*-openbsd* \
775  | powerpc*-*-rtems* \
776  | powerpc*-*-solaris* | powerpc*-*-kaos* | powerpc*-*-vxworks*)
777			case "${targ}" in
778			powerpc64*)
779			    targ_emul=elf64ppc
780			    targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim"
781			    targ_extra_libpath="elf32ppc elf32ppclinux" ;;
782			*linux*)
783			    targ_emul=elf32ppclinux
784			    targ_extra_emuls="elf32ppc elf32ppcsim"
785			    targ_extra_libpath=elf32ppc
786			    targ64_extra_emuls=elf64ppc
787			    targ64_extra_libpath=elf64ppc ;;
788			*)
789			    targ_emul=elf32ppc
790			    targ_extra_emuls="elf32ppclinux elf32ppcsim"
791			    targ_extra_libpath=elf32ppclinux
792			    targ64_extra_emuls=elf64ppc
793			    targ64_extra_libpath=elf64ppc ;;
794			esac
795			td=tdir_elf32ppc
796			td64=tdir_elf64ppc
797			s=s/ppc/lppc/g
798			case "${targ}" in
799			powerpcle-* | powerpc64le-*)
800			    for z in td td64 targ_emul targ_extra_emuls \
801					 targ_extra_libpath targ64_extra_emuls \
802					 targ64_extra_libpath
803			    do
804				eval ${z}=\"\`echo \$${z} \| sed -e $s\`\"
805			    done
806			    s=s/lppc/ppc/g ;;
807			esac
808			# Why oh why did we set tooldir based on target_alias
809			# rather than on target?
810			eval tdir_${targ_emul}="${targ_alias}"
811			cpu=`echo "${targ_alias}" | sed -e 's/-.*//'`
812			rest=`echo "${targ_alias}" | sed -e 's/^[^-]*//'`
813			le=le
814			case "${cpu}" in
815			*little) le=little
816			esac
817			ta32=`echo "${cpu}" | sed -e s/64//`"${rest}"
818			ta64=`echo "${cpu}" | sed -e 's/64//;s/$/64/;s/'${le}'64$/64'${le}'/;s/be64$/64be/'`"${rest}"
819			eval test -n \"\$${td}\" || eval ${td}="${ta32}"
820			eval test -n \"\$${td}linux\" || eval ${td}linux="${ta32}"
821			eval test -n \"\$${td}sim\" || eval ${td}sim="${ta32}"
822			eval test -n \"\$${td64}\" || eval ${td64}="${ta64}"
823			# Now provide the other endian
824			for z in targ_extra_emuls targ_extra_libpath
825			do
826			    eval ${z}=\"\$${z} \`echo ${targ_emul} \$${z} \| sed -e $s\`\"
827			done
828			for z in targ64_extra_emuls targ64_extra_libpath
829			do
830			    eval ${z}=\"\$${z} \`echo \$${z} \| sed -e $s\`\"
831			done
832			td=`echo "${td}" | sed -e $s`
833			td64=`echo "${td64}" | sed -e $s`
834			case "${targ}" in
835			powerpcle-* | powerpc64le-*)
836			    cpu=`echo "${cpu}" | sed -e s/${le}\$//` ;;
837			*)
838			    cpu=`echo "${cpu}" | sed -e s/be\$//`${le} ;;
839			esac
840			ta32=`echo "${cpu}" | sed -e s/64//`"${rest}"
841			ta64=`echo "${cpu}" | sed -e 's/64//;s/$/64/;s/'${le}'64$/64'${le}/`"${rest}"
842			eval test -n \"\$${td}\" || eval ${td}="${ta32}"
843			eval test -n \"\$${td}linux\" || eval ${td}linux="${ta32}"
844			eval test -n \"\$${td}sim\" || eval ${td}sim="${ta32}"
845			eval test -n \"\$${td64}\" || eval ${td64}="${ta64}"
846			;;
847powerpc-*-nto*)		targ_emul=elf32ppcnto
848			;;
849powerpcle-*-nto*)	targ_emul=elf32lppcnto
850			;;
851powerpc-*-macos*)	targ_emul=ppcmacos
852			targ_extra_ofiles=
853			;;
854powerpc-*-aix[5-9]*)	targ_emul=aix5ppc
855			targ_extra_ofiles=
856			;;
857powerpc-*-aix*)		targ_emul=aixppc
858			targ_extra_ofiles=
859			;;
860powerpc-*-beos*)	targ_emul=aixppc
861			targ_extra_ofiles=
862			;;
863powerpc-*-haiku*)	targ_emul=elf32ppchaiku
864			;;
865powerpc-*-windiss*)	targ_emul=elf32ppcwindiss
866			;;
867pru*-*-*)		targ_emul=pruelf
868			;;
869riscv32be*-*-linux* | riscv32be*-*-netbsd*)
870			targ_emul=elf32briscv
871			targ_extra_emuls="elf32briscv_ilp32f elf32briscv_ilp32 elf64briscv elf64briscv_lp64f elf64briscv_lp64 elf32lriscv elf32lriscv_ilp32f elf32lriscv_ilp32 elf64lriscv elf64lriscv_lp64f elf64lriscv_lp64"
872			targ_extra_libpath=$targ_extra_emuls
873			;;
874riscv32*-*-linux* | riscv-*-netbsd* | riscv32*-*-netbsd*)
875			targ_emul=elf32lriscv
876			targ_extra_emuls="elf32lriscv_ilp32f elf32lriscv_ilp32 elf64lriscv elf64lriscv_lp64f elf64lriscv_lp64 elf32briscv elf32briscv_ilp32f elf32briscv_ilp32 elf64briscv elf64briscv_lp64f elf64briscv_lp64"
877			targ_extra_libpath=$targ_extra_emuls
878			;;
879riscvbe-*-* | riscv32be*-*-*)
880			targ_emul=elf32briscv
881			targ_extra_emuls="elf64briscv elf32lriscv elf64lriscv"
882			targ_extra_libpath=$targ_extra_emuls
883			;;
884riscv-*-* | riscv32*-*-*)
885			targ_emul=elf32lriscv
886			targ_extra_emuls="elf64lriscv elf32briscv elf64briscv"
887			targ_extra_libpath=$targ_extra_emuls
888			;;
889riscv64be*-*-linux* | riscv64be*-*-netbsd*)
890			targ_emul=elf64briscv
891			targ_extra_emuls="elf64briscv_lp64f elf64briscv_lp64 elf32briscv elf32briscv_ilp32f elf32briscv_ilp32 elf64lriscv elf64lriscv_lp64f elf64lriscv_lp64 elf32lriscv elf32lriscv_ilp32f elf32lriscv_ilp32"
892			targ_extra_libpath=$targ_extra_emuls
893			;;
894riscv64*-*-linux* | riscv64*-*-netbsd*)
895			targ_emul=elf64lriscv
896			targ_extra_emuls="elf64lriscv_lp64f elf64lriscv_lp64 elf32lriscv elf32lriscv_ilp32f elf32lriscv_ilp32 elf64briscv elf64briscv_lp64f elf64briscv_lp64 elf32briscv elf32briscv_ilp32f elf32briscv_ilp32"
897			targ_extra_libpath=$targ_extra_emuls
898			;;
899riscv64be*-*-*)		targ_emul=elf64briscv
900			targ_extra_emuls="elf32briscv elf64lriscv elf32lriscv"
901			targ_extra_libpath=$targ_extra_emuls
902			;;
903riscv64*-*-*)		targ_emul=elf64lriscv
904			targ_extra_emuls="elf32lriscv elf64briscv elf32briscv"
905			targ_extra_libpath=$targ_extra_emuls
906			;;
907rs6000-*-aix[5-9]*)	targ_emul=aix5rs6
908			targ_extra_ofiles=
909			;;
910rs6000-*-aix*)		targ_emul=aixrs6
911			targ_extra_ofiles=
912			;;
913rl78-*-*)		targ_emul=elf32rl78
914			;;
915rx-*-linux*)		targ_emul=elf32rx_linux
916			;;
917rx-*-*)			targ_emul=elf32rx
918			;;
919s12z-*-*)		targ_emul=m9s12zelf
920			targ_extra_ofiles=ldelfgen.o
921			;;
922s390x-*-linux*)		targ_emul=elf64_s390
923			targ_extra_emuls=elf_s390
924			targ_extra_libpath=$targ_extra_emuls
925			tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'`
926			;;
927s390x-*-tpf*)		targ_emul=elf64_s390
928			tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'`
929			;;
930s390-*-linux*)		targ_emul=elf_s390
931			targ64_extra_emuls=elf64_s390
932			targ64_extra_libpath=elf64_s390
933			tdir_elf64_s390=`echo ${targ_alias} | sed -e 's/s390/s390x/'`
934			;;
935score-*-elf)		targ_emul=score7_elf
936			targ_extra_emuls=score3_elf
937			;;
938sh-*-linux*)		targ_emul=shlelf_linux
939			targ_extra_emuls="shelf_linux shlelf_fd shelf_fd"
940			targ_extra_libpath=shelf_linux
941			;;
942sh*eb-*-linux*)		targ_emul=shelf_linux
943			targ_extra_emuls="shelf_fd"
944			;;
945sh*-*-linux*)		targ_emul=shlelf_linux
946			targ_extra_emuls="shlelf_fd"
947			;;
948sh*l*-*-netbsd*)	targ_emul=shlelf_nbsd
949			targ_extra_emuls=shelf_nbsd
950			;;
951sh*-*-netbsd*)	targ_emul=shelf_nbsd
952			targ_extra_emuls=shlelf_nbsd
953			;;
954shle*-*-elf* | sh[1234]*le*-*-elf | shle*-*-kaos*)
955			targ_emul=shlelf
956			targ_extra_emuls="shelf shl sh"
957			;;
958sh-*-elf* | sh[1234]*-*-elf | sh-*-rtems* | sh-*-kaos*)
959			targ_emul=shelf
960			targ_extra_emuls="shlelf sh shl"
961			;;
962sh-*-uclinux* | sh[12]-*-uclinux*)
963			targ_emul=shelf_uclinux
964			targ_extra_emuls="shelf shlelf sh shl shelf_fd shlelf_fd"
965			;;
966sh-*-vxworks)		targ_emul=shelf_vxworks
967			targ_extra_emuls=shlelf_vxworks
968			;;
969sh-*-nto*)		targ_emul=shelf_nto
970			targ_extra_emuls=shlelf_nto
971			;;
972sh-*-pe)		targ_emul=shpe ;
973			targ_extra_ofiles="deffilep.o pe-dll.o"
974			;;
975sh-*-*)			targ_emul=sh;
976			targ_extra_emuls=shl
977			targ_extra_ofiles=
978			;;
979sparc64-*-freebsd* | sparcv9-*-freebsd* | sparc64-*-kfreebsd*-gnu | sparcv9-*-kfreebsd*-gnu)
980			targ_emul=elf64_sparc_fbsd
981			targ_extra_emuls="elf64_sparc elf32_sparc"
982			targ_extra_libpath=$targ_extra_emuls
983			tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
984			;;
985sparc64-*-linux-*)	targ_emul=elf64_sparc
986			targ_extra_emuls="elf32_sparc"
987			targ_extra_libpath=elf32_sparc
988			tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
989			;;
990sparc64-*-*bsd*)	targ_emul=elf64_sparc
991			targ_extra_emuls="elf32_sparc"
992			;;
993sparc64-*-solaris2* | sparcv9-*-solaris2*)
994			targ_emul=elf64_sparc_sol2
995			targ_extra_emuls="elf64_sparc elf32_sparc_sol2 elf32_sparc"
996			targ_extra_libpath=$targ_extra_emuls
997			tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
998			;;
999sparc64-*-haiku*)	targ_emul=elf64_sparc
1000			;;
1001sparc64-*-*)		targ_emul=elf64_sparc
1002			;;
1003sparc*-*-linux-*)	targ_emul=elf32_sparc
1004			targ_extra_emuls="elf64_sparc"
1005			targ_extra_libpath=elf64_sparc
1006			tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'`
1007			;;
1008sparc64-*-netbsd*)	targ_emul=elf64_sparc
1009			targ_extra_emuls="elf32_sparc"
1010			;;
1011sparc*-*-netbsd*)	targ_emul=elf32_sparc
1012			;;
1013sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*)
1014			targ_emul=elf32_sparc_sol2
1015			targ_extra_emuls=elf32_sparc
1016			;;
1017sparc-*-solaris2*)	targ_emul=elf32_sparc_sol2
1018			targ_extra_emuls="elf32_sparc elf64_sparc_sol2 elf64_sparc"
1019			targ_extra_libpath=$targ_extra_emuls
1020			tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'`
1021			;;
1022sparc*-*-vxworks*)	targ_emul=elf32_sparc_vxworks
1023			;;
1024sparc*-*-*)		targ_emul=elf32_sparc
1025			;;
1026spu-*-elf*)		targ_emul=elf32_spu
1027			;;
1028tic30-*-*coff*)		targ_emul=tic30coff
1029			targ_extra_ofiles=
1030			;;
1031tic4x-*-* | c4x-*-*)	targ_emul=tic4xcoff
1032			targ_extra_emuls="tic3xcoff tic3xcoff_onchip"
1033			targ_extra_ofiles=
1034			;;
1035tic54x-*-* | c54x*-*-*)	targ_emul=tic54xcoff
1036			targ_extra_ofiles=
1037			;;
1038tic6x-*-elf)		targ_emul=elf32_tic6x_elf_le
1039			targ_extra_emuls="elf32_tic6x_elf_be elf32_tic6x_le elf32_tic6x_be"
1040			targ_extra_libpath=$targ_extra_emuls
1041			;;
1042tic6x-*-uclinux)	targ_emul=elf32_tic6x_linux_le
1043			targ_extra_emuls="elf32_tic6x_linux_be elf32_tic6x_le elf32_tic6x_be"
1044			targ_extra_libpath=$targ_extra_emuls
1045			;;
1046tilegx-*-*)		targ_emul=elf64tilegx
1047			targ_extra_emuls="elf64tilegx_be elf32tilegx elf32tilegx_be"
1048			targ_extra_libpath=$targ_extra_emuls
1049			;;
1050tilegxbe-*-*)		targ_emul=elf64tilegx_be
1051			targ_extra_emuls="elf64tilegx elf32tilegx elf32tilegx_be"
1052			targ_extra_libpath=$targ_extra_emuls
1053			;;
1054tilepro-*-*)		targ_emul=elf32tilepro
1055			;;
1056v850*-*-*)		targ_emul=v850_rh850
1057			targ_extra_emuls=v850
1058			;;
1059vax-*-netbsdaout*)	targ_emul=vaxnbsd
1060			targ_extra_emuls=elf32vax
1061			;;
1062vax-*-netbsd*)		targ_emul=elf32vax
1063			targ_extra_emuls=vaxnbsd
1064			;;
1065vax-*-linux-*)		targ_emul=elf32vax
1066			;;
1067visium-*-elf)		targ_emul=elf32visium
1068			;;
1069x86_64-*-rdos*)		targ_emul=elf64rdos
1070			;;
1071x86_64-*-cloudabi*)	targ_emul=elf_x86_64_cloudabi
1072			;;
1073x86_64-*-haiku*)	targ_emul=elf_x86_64_haiku
1074			targ_extra_emuls="elf_x86_64 elf_i386_haiku"
1075			;;
1076x86_64-*-linux-gnux32)	targ_emul=elf32_x86_64
1077			targ_extra_emuls="elf_x86_64 elf_i386 elf_iamcu"
1078			targ_extra_libpath="elf_i386 elf_iamcu elf_x86_64"
1079			tdir_elf_iamcu=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
1080			tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
1081			;;
1082x86_64-*-linux-*)	targ_emul=elf_x86_64
1083			targ_extra_emuls="elf32_x86_64 elf_i386 elf_iamcu"
1084			targ_extra_libpath="elf_i386 elf32_x86_64"
1085			tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
1086			;;
1087x86_64-*-redox*)	targ_emul=elf_x86_64
1088			targ_extra_emuls=elf_i386
1089			;;
1090x86_64-*-solaris2*)	targ_emul=elf_x86_64_sol2
1091			targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu"
1092			targ_extra_libpath=$targ_extra_emuls
1093			tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
1094			;;
1095x86_64-*-netbsd* | x86_64-*-openbsd*)
1096			targ_emul=elf_x86_64
1097			targ_extra_emuls="elf_i386 elf_iamcu"
1098			tdir_elf_iamcu=`echo ${targ_alias} | \
1099			    sed -e 's/x86_64/i386/' -e 's/aout//'`
1100			tdir_elf_i386=`echo ${targ_alias} | \
1101			    sed -e 's/x86_64/i386/' -e 's/aout//'`
1102			;;
1103x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia* | x86_64-*-genode*)
1104			targ_emul=elf_x86_64
1105			targ_extra_emuls="elf_i386 elf_iamcu elf32_x86_64"
1106			targ_extra_libpath="elf_i386 elf_iamcu elf32_x86_64"
1107			tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
1108			;;
1109x86_64-*-dragonfly*)	targ_emul=elf_x86_64
1110			targ_extra_emuls="elf_i386 elf_iamcu"
1111			;;
1112x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
1113			targ_emul=elf_x86_64_fbsd
1114			targ_extra_emuls="elf_i386_fbsd elf_x86_64 elf_i386 elf_iamcu"
1115			targ_extra_libpath="elf_i386_fbsd"
1116			tdir_elf_i386_fbsd=`echo ${targ_alias} \
1117			    | sed -e 's/x86_64/i386/'`
1118			tdir_elf_iamcu=`echo ${targ_alias} \
1119			    | sed -e 's/x86_64/i386/'`
1120			tdir_elf_i386=`echo ${targ_alias} \
1121			    | sed -e 's/x86_64/i386/'`
1122			;;
1123x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
1124			targ_extra_emuls=i386pe ;
1125			targ_extra_ofiles="deffilep.o pdb.o pep-dll-x86_64.o pe-dll.o"
1126			;;
1127x86_64-*-cygwin)	targ_emul=i386pep ;
1128			targ_extra_emuls=i386pe
1129			targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
1130			test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api'
1131			;;
1132x86_64-*-mingw*)	targ_emul=i386pep ;
1133			targ_extra_emuls=i386pe
1134			targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
1135			;;
1136x86_64-*-gnu*)		targ_emul=elf_x86_64
1137			targ_extra_emuls="elf32_x86_64 elf_iamcu elf_i386"
1138			targ_extra_libpath="elf_i386 elf32_x86_64"
1139			tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
1140			;;
1141xgate-*-*)		targ_emul=xgateelf
1142			targ_extra_ofiles=ldelfgen.o
1143			;;
1144xstormy16-*-*)		targ_emul=elf32xstormy16
1145			;;
1146xtensa*-*-*)		targ_emul=elf32xtensa
1147			;;
1148z80-*-elf*)		targ_emul=elf32z80
1149			targ_extra_ofiles="ldelf.o ldelfgen.o"
1150			;;
1151z80-*-coff)		targ_emul=z80
1152			targ_extra_ofiles=
1153			;;
1154z8k-*-coff)		targ_emul=z8002
1155			targ_extra_emuls=z8001
1156			targ_extra_ofiles=
1157			;;
1158loongarch32-*)		targ_emul=elf32loongarch
1159			;;
1160loongarch64-*)		targ_emul=elf64loongarch
1161			;;
1162*-*-ieee*)		targ_emul=vanilla
1163			targ_extra_ofiles=
1164			;;
1165*)
1166  echo 2>&1 "*** ld does not support target ${targ}"
1167  echo 2>&1 "*** see ld/configure.tgt for supported targets"
1168  exit 1
1169
1170esac
1171
1172NATIVE_LIB_DIRS='/usr/local/lib /lib /usr/lib'
1173case "${target}" in
1174
1175*-*-dragonfly*)
1176  NATIVE_LIB_DIRS='/lib /usr/lib /usr/pkg/lib /usr/local/lib'
1177  ;;
1178
1179*-*-freebsd*)
1180  NATIVE_LIB_DIRS='/lib /usr/lib /usr/local/lib'
1181  ;;
1182
1183hppa*64*-*-hpux11*)
1184  NATIVE_LIB_DIRS=/usr/lib/pa20_64
1185  ;;
1186
1187i[3-7]86-*-sysv4*)
1188  NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
1189  ;;
1190
1191i[3-7]86-*-solaris*)
1192  NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
1193  ;;
1194
1195i[3-7]86-pc-interix*)
1196  NATIVE_LIB_DIRS='/usr/local/lib $$INTERIX_ROOT/usr/lib /lib /usr/lib'
1197  ;;
1198
1199ia64-*-aix*)
1200  NATIVE_LIB_DIRS='/usr/local/lib /usr/lib/ia64l64 /lib /usr/lib'
1201  ;;
1202
1203sparc*-*-solaris2*)
1204  NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
1205  ;;
1206
1207spu-*-elf*)
1208  # This allows one to build a pair of PPU/SPU toolchains with common sysroot.
1209  NATIVE_LIB_DIRS='/lib'
1210  ;;
1211
1212i[03-9x]86-*-cygwin* | x86_64-*-cygwin*)
1213  NATIVE_LIB_DIRS='/usr/lib /usr/lib/w32api'
1214  ;;
1215
1216*-*-linux*)
1217  ;;
1218
1219*-*-netbsd*)
1220  ;;
1221
1222alpha*-*-*)
1223  NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
1224  ;;
1225
1226esac
1227
1228case "${target}" in
1229frv-*-* | hppa*-*-* | ia64-*-* | mips*-*-*)
1230  # Don't enable -z relro by default since many relro tests fail on these
1231  # targets:
1232  # FAIL: strip -z relro (relro1)
1233  # FAIL: strip -z relro -shared (relro1)
1234  # FAIL: objcopy -z relro (relro1)
1235  # FAIL: objcopy -z relro -shared (relro1)
1236  # FAIL: objcopy -z relro (tdata1)
1237  # FAIL: objcopy -shared -z relro (tdata1)
1238  # FAIL: objcopy -z relro (tdata2)
1239  # FAIL: objcopy -shared -z relro (tdata2)
1240  # FAIL: objcopy -z relro (tdata3)
1241  # FAIL: objcopy -shared -z relro (tdata3)
1242  # FAIL: objcopy -shared -z relro (tbss1)
1243  # FAIL: objcopy -shared -z relro (tbss2)
1244  # FAIL: objcopy -shared -z relro (tbss3)
1245  ;;
1246*-*-linux*)
1247  if test ${ac_default_ld_z_relro} = unset; then
1248    ac_default_ld_z_relro=1
1249  fi
1250  ;;
1251esac
1252
1253# Enable -z separate-code and --warn-textrel by default for Linux/x86.
1254case "${target}" in
1255i[3-7]86-*-linux-* | x86_64-*-linux-* | i[3-7]86-*-netbsd* | x86_64-*-netbsd*)
1256  if test ${ac_default_ld_z_separate_code} = unset; then
1257    ac_default_ld_z_separate_code=1
1258  fi
1259  if test ${ac_default_ld_textrel_check} = unset; then
1260    ac_default_ld_textrel_check=yes
1261  fi
1262  ;;
1263esac
1264