]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/configure.tgt
Add support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure. Add an...
[thirdparty/binutils-gdb.git] / ld / configure.tgt
index 56945808c988d7e7a68ceae5677d132965b989cd..18c3ba4c4d43539974ac0c758beb124b72202867 100644 (file)
@@ -1,17 +1,17 @@
 # configure.tgt
 #
-#   Copyright 2013 Free Software Foundation
+#   Copyright (C) 2013-2020 Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 #  targ_emul           name of linker emulation to use
 #  targ_extra_emuls    additional linker emulations to provide
 #  targ_extra_libpath  additional linker emulations using LIB_PATH
-#  targ_extra_ofiles   additional objects needed by the emulation
+#  targ_extra_ofiles   additional host-compiled objects needed by the emulation
 #  targ64_extra_emuls  additional linker emulations to provide if
-#                      --enable-64-bit-bfd is given or if host is 64 bit.
+#                      --enable-64-bit-bfd is given or if host is 64 bit.
 #  targ64_extra_libpath        additional linker emulations using LIB_PATH if
-#                      --enable-64-bit-bfd is given or if host is 64 bit.
+#                      --enable-64-bit-bfd is given or if host is 64 bit.
 #  NATIVE_LIB_DIRS     library directories to search on this host
 #                      (if we are a native or sysrooted linker)
 
 targ_extra_emuls=
 targ_extra_libpath=
-targ_extra_ofiles=
+targ_extra_ofiles="ldelf.o ldelfgen.o"
 targ64_extra_emuls=
 targ64_extra_libpath=
 
-# Please try to keep this table in alphabetic order - it makes it
-# much easier to lookup a specific archictecture.  Naturally any
-# architecture variants should be kept together even if their names
-# break the alpha sorting.
+# Please try to keep this table more or less in alphabetic order - it
+# makes it much easier to lookup a specific archictecture.
 case "${targ}" in
 aarch64_be-*-elf)      targ_emul=aarch64elfb
-                       targ_extra_emuls="aarch64elf armelfb armelf" ;;
-aarch64-*-elf)         targ_emul=aarch64elf
-                       targ_extra_emuls="aarch64elfb armelf armelfb" ;;
+                       targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b armelfb armelf"
+                       ;;
+aarch64-*-elf | aarch64-*-rtems*)
+                       targ_emul=aarch64elf
+                       targ_extra_emuls="aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb"
+                       ;;
+aarch64-*-cloudabi*)   targ_emul=aarch64cloudabi
+                       targ_extra_emuls=aarch64cloudabib
+                       ;;
+aarch64-*-freebsd*)    targ_emul=aarch64fbsd
+                       targ_extra_emuls="aarch64fbsdb aarch64elf"
+                       ;;
+aarch64-*-fuchsia*)    targ_emul=aarch64elf
+                       targ_extra_emuls="aarch64elfb armelf armelfb"
+                       ;;
+aarch64_be-*-linux-gnu_ilp32)
+                       targ_emul=aarch64linux32b
+                       targ_extra_libpath="aarch64linuxb aarch64linux aarch64linux32 armelfb_linux_eabi armelf_linux_eabi"
+                       targ_extra_emuls="aarch64elfb aarch64elf aarch64elf32 aarch64elf32b armelfb armelf $targ_extra_libpath"
+                       ;;
+aarch64-*-linux-gnu_ilp32)
+                       targ_emul=aarch64linux32
+                       targ_extra_libpath="aarch64linux aarch64linuxb aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
+                       targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb $targ_extra_libpath"
+                       ;;
 aarch64_be-*-linux*)   targ_emul=aarch64linuxb
-                       targ_extra_emuls="aarch64linux aarch64elfb aarch64elf armelfb_linux_eabi armelf_linux_eabi armelfb armelf" ;;
+                       targ_extra_libpath="aarch64linux aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
+                       targ_extra_emuls="aarch64elfb aarch64elf aarch64elf32 aarch64elf32b armelfb armelf $targ_extra_libpath"
+                       ;;
 aarch64-*-linux*)      targ_emul=aarch64linux
-                       targ_extra_emuls="aarch64linuxb aarch64elf aarch64elfb armelf_linux_eabi armelfb_linux_eabi armelf armelfb" ;;
+                       targ_extra_libpath="aarch64linuxb aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
+                       targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb $targ_extra_libpath"
+                       ;;
 alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
-                       targ_emul=elf64alpha_fbsd
+                       targ_emul=elf64alpha_fbsd
                        targ_extra_emuls="elf64alpha alpha"
-                       tdir_alpha=`echo ${targ_alias} | sed -e 's/freebsd/freebsdecoff/'` ;;
-alpha*-*-linux*ecoff*) targ_emul=alpha targ_extra_emuls=elf64alpha
-                       tdir_elf64alpha=`echo ${targ_alias} | sed -e 's/ecoff//'` ;;
-alpha*-*-linux-*)      targ_emul=elf64alpha targ_extra_emuls=alpha
-                       tdir_alpha=`echo ${targ_alias} | sed -e 's/linux\(-gnu\)*/linux\1ecoff/'` ;;
-alpha*-*-osf*)         targ_emul=alpha ;;
-alpha*-*-gnu*)         targ_emul=elf64alpha ;;
-alpha*-*-netware*)     targ_emul=alpha ;;
-alpha*-*-netbsd*)      targ_emul=elf64alpha_nbsd ;;
-alpha*-*-openbsd*)     targ_emul=elf64alpha ;;
+                       tdir_alpha=`echo ${targ_alias} | sed -e 's/freebsd/freebsdecoff/'`
+                       ;;
+alpha*-*-linux*ecoff*) targ_emul=alpha
+                       targ_extra_emuls=elf64alpha
+                       tdir_elf64alpha=`echo ${targ_alias} | sed -e 's/ecoff//'`
+                       ;;
+alpha*-*-linux-*)      targ_emul=elf64alpha
+                       targ_extra_emuls=alpha
+                       tdir_alpha=`echo ${targ_alias} | sed -e 's/linux\(-gnu\)*/linux\1ecoff/'`
+                       ;;
+alpha*-*-osf*)         targ_emul=alpha
+                       targ_extra_ofiles=
+                       ;;
+alpha*-*-gnu*)         targ_emul=elf64alpha
+                       ;;
+alpha*-*-netbsd*)      targ_emul=elf64alpha_nbsd
+                       ;;
+alpha*-*-openbsd*)     targ_emul=elf64alpha
+                       ;;
 alpha*-*-*vms*)                targ_emul=alphavms
+                       targ_extra_ofiles=
                        ;;
-arc-*-elf*)            targ_emul=arcelf
+am33_2.0-*-linux*)     targ_emul=elf32am33lin # mn10300 variant
+                       ;;
+arc*-*-elf*)           targ_emul=arcelf
+                       targ_extra_emuls="arcelf_prof arclinux arclinux_nps arclinux_prof arcv2elf arcv2elfx"
+                       ;;
+arc*-*-linux*)         case "${with_cpu}" in
+                       nps400) targ_emul=arclinux_nps
+                               targ_extra_emuls=arclinux
+                               ;;
+                       *)      targ_emul=arclinux
+                               targ_extra_emuls=arclinux_nps
+                               ;;
+                       esac
+                       targ_extra_emuls="${targ_extra_emuls} arclinux_prof arcelf arcelf_prof arcv2elf arcv2elfx"
+                       ;;
+arm*-*-cegcc*)         targ_emul=arm_wince_pe
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       LIB_PATH='${tooldir}/lib/w32api'
                        ;;
-arm-epoc-pe)           targ_emul=arm_epoc_pe ; targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-arm*-*-cegcc*)         targ_emul=arm_wince_pe ; targ_extra_ofiles="deffilep.o pe-dll.o"
-                       LIB_PATH='${tooldir}/lib/w32api' ;;
 arm-wince-pe | arm-*-wince | arm*-*-mingw32ce*)
-                       targ_emul=arm_wince_pe ; targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-arm-*-pe)              targ_emul=armpe ; targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-arm-*-aout | armel-*-aout) targ_emul=armaoutl ;;
-armeb-*-aout)          targ_emul=armaoutb ;;
-arm-*-coff)            targ_emul=armcoff ;;
-arm-*-freebsd* | arm-*-kfreebsd*-gnu)
-                       targ_emul=armelf_fbsd
-                       targ_extra_emuls="armelf" ;;
+                       targ_emul=arm_wince_pe
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
+arm-*-pe)              targ_emul=armpe
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
+arm*b-*-freebsd*)      targ_emul=armelfb_fbsd
+                       targ_extra_emuls="armelf_fbsd armelf"
+                       ;;
+arm*-*-freebsd* | arm-*-kfreebsd*-gnu)
+                       targ_emul=armelf_fbsd
+                       targ_extra_emuls="armelfb_fbsd armelf"
+                       ;;
 armeb-*-netbsdelf*)    targ_emul=armelfb_nbsd;
-                       targ_extra_emuls="armelf_nbsd armelf armnbsd" ;;
+                       targ_extra_emuls="armelf_nbsd armelf"
+                       ;;
 arm-*-netbsdelf*)      targ_emul=armelf_nbsd;
-                       targ_extra_emuls="armelfb_nbsd armelf armnbsd" ;;
-arm-*-netbsd*)         targ_emul=armnbsd;
-                       targ_extra_emuls="armelf armelf_nbsd armelfb_nbsd"  ;;
-arm-*-nto*)            targ_emul=armnto ;;
-arm-*-openbsd*)                targ_emul=armnbsd ;;
-arm-*-rtems*)          targ_emul=armelf ;;
-armeb-*-elf)           targ_emul=armelfb ;;
-arm-*-elf | arm*-*-eabi*)
-                       targ_emul=armelf ;;
-arm*-*-symbianelf*)     targ_emul=armsymbian;;
-arm-*-kaos*)           targ_emul=armelf ;;
-arm9e-*-elf)           targ_emul=armelf ;;
+                       targ_extra_emuls="armelfb_nbsd armelf"
+                       ;;
+arm-*-nto*)            targ_emul=armnto
+                       ;;
+arm-*-phoenix*)                targ_emul=armelf
+                       ;;
+armeb-*-elf | armeb-*-eabi*)
+                       targ_emul=armelfb
+                       ;;
+arm-*-elf | arm*-*-eabi* | arm-*-rtems*)
+                       targ_emul=armelf
+                       ;;
+arm*-*-symbianelf*)    targ_emul=armsymbian;;
+arm-*-kaos*)           targ_emul=armelf
+                       ;;
+arm9e-*-elf)           targ_emul=armelf
+                       ;;
 arm*b-*-linux-*eabi*)  targ_emul=armelfb_linux_eabi
                        targ_extra_emuls=armelf_linux_eabi
                        targ_extra_libpath=$targ_extra_emuls
@@ -106,10 +165,15 @@ arm*b-*-linux-*)  targ_emul=armelfb_linux
                        targ_extra_libpath="armelf_linux"
                        ;;
 arm*-*-linux-*eabi*)   targ_emul=armelf_linux_eabi
-                       targ_extra_emuls=armelfb_linux_eabi
+                       targ_extra_emuls="armelfb_linux_eabi"
                        targ_extra_libpath=$targ_extra_emuls
                        ;;
-arm*-*-linux-*)                targ_emul=armelf_linux
+arm*-*-uclinuxfdpiceabi)
+                       targ_emul=armelf_linux_eabi
+                       targ_extra_emuls="armelfb_linux_eabi armelf_linux_fdpiceabi armelfb_linux_fdpiceabi"
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+arm*-*-linux-*)                targ_emul=armelf_linux
                        targ_extra_emuls="armelf armelfb armelfb_linux"
                        targ_extra_libpath="armelfb_linux"
                        ;;
@@ -133,16 +197,18 @@ arm*-*-uclinux*)  targ_emul=armelf_linux
                        targ_extra_emuls="armelf armelfb armelfb_linux"
                        targ_extra_libpath="armelfb_linux"
                        ;;
-arm-*-vxworks)         targ_emul=armelf_vxworks ;;
-arm*-*-conix*)         targ_emul=armelf ;;
-avr-*-*)               targ_emul=avr2
-                       targ_extra_emuls="avr1 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega1 avrxmega2 avrxmega3 avrxmega4 avrxmega5 avrxmega6 avrxmega7"
+arm-*-vxworks)         targ_emul=armelf_vxworks
                        ;;
-bfin-*-elf)            targ_emul=elf32bfin;
-                       targ_extra_emuls="elf32bfinfd"
-                       targ_extra_libpath=$targ_extra_emuls
+arm*-*-conix*)         targ_emul=armelf
                        ;;
-bfin-*-rtems*)         targ_emul=elf32bfin;
+arm*-*-fuchsia*)       targ_emul=armelf_fuchsia
+                       targ_extra_emuls="armelfb_fuchsia armelf armelfb"
+                       ;;
+avr-*-*)               targ_emul=avr2
+                       targ_extra_emuls="avr1 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega1 avrxmega2 avrxmega3 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny"
+                       ;;
+bfin-*-elf | bfin-*-rtems*)
+                       targ_emul=elf32bfin
                        targ_extra_emuls="elf32bfinfd"
                        targ_extra_libpath=$targ_extra_emuls
                        ;;
@@ -154,182 +220,188 @@ bfin-*-linux-uclibc*)   targ_emul=elf32bfinfd;
                        targ_extra_emuls="elf32bfin"
                        targ_extra_libpath=$targ_extra_emuls
                        ;;
-cr16-*-elf*)            targ_emul=elf32cr16 ;;
-cr16c-*-elf*)           targ_emul=elf32cr16c
+bpf-*-*)               targ_emul=elf64bpf
+                       ;;
+cr16-*-elf*)           targ_emul=elf32cr16
                        ;;
 cris-*-*aout*)         targ_emul=crisaout
                        targ_extra_emuls="criself crislinux"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 cris-*-linux-* | crisv32-*-linux-*)
-                       targ_emul=crislinux ;;
+                       targ_emul=crislinux
+                       ;;
 cris-*-* | crisv32-*-*)        targ_emul=criself
                        targ_extra_emuls="crisaout crislinux"
                        targ_extra_libpath=$targ_extra_emuls
                        ;;
 crx-*-elf*)            targ_emul=elf32crx
                        ;;
-d10v-*-*)              targ_emul=d10velf ;;
-d30v-*-*ext*)          targ_emul=d30v_e; targ_extra_emuls="d30velf d30v_o" ;;
-d30v-*-*onchip*)       targ_emul=d30v_o; targ_extra_emuls="d30velf d30v_e" ;;
-d30v-*-*)              targ_emul=d30velf; targ_extra_emuls="d30v_e d30v_o"
+
+csky-*-elf*)           targ_emul=cskyelf
+                       ;;
+csky-*-linux*)         targ_emul=cskyelf_linux
+                       ;;
+
+d10v-*-*)              targ_emul=d10velf
+                       ;;
+d30v-*-*ext*)          targ_emul=d30v_e
+                       targ_extra_emuls="d30velf d30v_o"
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
+d30v-*-*onchip*)       targ_emul=d30v_o
+                       targ_extra_emuls="d30velf d30v_e"
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
+d30v-*-*)              targ_emul=d30velf
+                       targ_extra_emuls="d30v_e d30v_o"
+                       targ_extra_ofiles=ldelfgen.o
                        ;;
 dlx-*-elf*)            targ_emul=elf32_dlx
+                       targ_extra_ofiles=ldelfgen.o
                        ;;
-epiphany-*-elf)                targ_emul=elf32epiphany
+epiphany-*-*)          targ_emul=elf32epiphany
                        targ_extra_emuls="elf32epiphany_4x4"
                        ;;
-fido*-*-elf*)          targ_emul=m68kelf ;;
+fido*-*-elf*)          targ_emul=m68kelf
+                       ;;
 fr30-*-*)              targ_emul=elf32fr30
+                       targ_extra_ofiles=ldelfgen.o
                        ;;
-frv-*-*linux*)         targ_emul=elf32frvfd ;;
-frv-*-*)               targ_emul=elf32frv ; targ_extra_emuls="elf32frvfd"
+frv-*-*linux*)         targ_emul=elf32frvfd
                        ;;
-moxie-*-*)             targ_emul=elf32moxie
+frv-*-*)               targ_emul=elf32frv
+                       targ_extra_emuls="elf32frvfd"
+                       ;;
+ft32-*-*)              targ_emul=elf32ft32
+                       targ_extra_ofiles=ldelfgen.o
                        ;;
-h8300-*-hms* | h8300-*-coff* | h8300-*-rtemscoff*)
-                       targ_emul=h8300; targ_extra_emuls="h8300h h8300s h8300hn h8300sn h8300sx h8300sxn" ;;
 h8300-*-elf* | h8300-*-rtems*)
                        targ_emul=h8300elf;
-                       targ_extra_emuls="h8300helf h8300self h8300hnelf h8300snelf h8300sxelf h8300sxnelf" ;;
-h8500-*-hms* | h8500-*-coff* | h8500-*-rtems*)
-                       targ_emul=h8500
-                       targ_extra_emuls="h8500s h8500b h8500m h8500c"
-                       ;;
-hppa*64*-*-linux-*)    targ_emul=hppa64linux ;;
-hppa*64*-hpux*)                targ_emul=elf64hppa ;;
-hppa*-*-linux-*)       targ_emul=hppalinux ;;
-hppa*-*-*elf*)         targ_emul=hppaelf ;;
-hppa*-*-lites*)                targ_emul=hppaelf ;;
-hppa*-*-netbsd*)       targ_emul=hppanbsd ;;
+                       targ_extra_emuls="h8300helf h8300self h8300hnelf h8300snelf h8300sxelf h8300sxnelf"
+                       ;;
+h8300-*-linux*)
+                       targ_emul=h8300elf_linux;
+                       targ_extra_emuls="h8300helf_linux h8300self_linux h8300sxelf_linux"
+                       ;;
+hppa*64*-*-linux-*)    targ_emul=hppa64linux
+                       ;;
+hppa*64*-hpux*)                targ_emul=elf64hppa
+                       ;;
+hppa*-*-linux-*)       targ_emul=hppalinux
+                       ;;
+hppa*-*-*elf*)         targ_emul=hppaelf
+                       ;;
+hppa*-*-lites*)                targ_emul=hppaelf
+                       ;;
+hppa*-*-netbsd*)       targ_emul=hppanbsd
+                       ;;
 hppa*-*-openbsd*)      targ_emul=hppaobsd
                        ;;
-i370-*-elf* | i370-*-linux-*) targ_emul=elf32i370
-                       ;;
-i[3-7]86-*-nto-qnx*)   targ_emul=i386nto ;;
-i[3-7]86-*-vsta)       targ_emul=vsta ;;
-i[3-7]86-*-go32)       targ_emul=i386go32 ;;
-i[3-7]86-*-msdosdjgpp*) targ_emul=i386go32 ;;
-i[3-7]86-*-aix*)       targ_emul=i386coff ;;
-i[3-7]86-*-sco*)       targ_emul=i386coff ;;
-i[3-7]86-*-isc*)       targ_emul=i386coff ;;
-i[3-7]86-*-lynxos*)    targ_emul=i386lynx ;;
-i[3-7]86-*-coff)       targ_emul=i386coff ;;
-i[3-7]86-*-rtems*)     targ_emul=elf_i386 ;;
-i[3-7]86-*-aros*)      targ_emul=elf_i386 ;;
-i[3-7]86-*-rdos*)      targ_emul=elf_i386 ;;
-x86_64-*-rdos*)                targ_emul=elf64rdos ;;
-i[3-7]86-*-bsd)                targ_emul=i386bsd ;;
-i[3-7]86-*-bsd386)     targ_emul=i386bsd ;;
-i[3-7]86-*-bsdi*)      targ_emul=i386bsd ;;
-i[3-7]86-*-aout)       targ_emul=i386aout ;;
-i[3-7]86-*-linux*aout*)        targ_emul=i386linux
-                       targ_extra_emuls=elf_i386
-                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'` ;;
-i[3-7]86-*-linux*oldld)        targ_emul=i386linux; targ_extra_emuls=elf_i386 ;;
+i[3-7]86-*-nto-qnx*)   targ_emul=i386nto
+                       ;;
+i[3-7]86-*-go32)       targ_emul=i386go32
+                       targ_extra_ofiles=
+                       ;;
+i[3-7]86-*-msdosdjgpp*) targ_emul=i386go32
+                       targ_extra_ofiles=
+                       ;;
+i[3-7]86-*-lynxos*)    targ_emul=i386lynx
+                       ;;
+i[3-7]86-*-aros*)      targ_emul=elf_i386
+                       targ_extra_emuls=elf_iamcu
+                       ;;
+i[3-7]86-*-rdos*)      targ_emul=elf_i386
+                       targ_extra_emuls=elf_iamcu
+                       ;;
+i[3-7]86-*-bsd)                targ_emul=i386bsd
+                       targ_extra_ofiles=
+                       ;;
+i[3-7]86-*-bsd386)     targ_emul=i386bsd
+                       targ_extra_ofiles=
+                       ;;
+i[3-7]86-*-bsdi*)      targ_emul=i386bsd
+                       targ_extra_ofiles=
+                       ;;
 i[3-7]86-*-linux-*)    targ_emul=elf_i386
-                       targ_extra_emuls=i386linux
+                       targ_extra_emuls="elf_iamcu"
                        targ64_extra_emuls="elf_x86_64 elf32_x86_64 elf_l1om elf_k1om"
-                       targ64_extra_libpath=elf_x86_64
-                       targ_extra_libpath=elf32_x86_64
-                       tdir_i386linux=${targ_alias}aout ;;
-x86_64-*-linux-gnux32) targ_emul=elf32_x86_64
-                       targ_extra_emuls="elf_x86_64 elf_i386 i386linux elf_l1om elf_k1om"
-                       targ_extra_libpath="elf_i386 elf_x86_64 elf_l1om elf_k1om"
-                       tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
-                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'` ;;
-x86_64-*-linux-*)      targ_emul=elf_x86_64
-                       targ_extra_emuls="elf32_x86_64 elf_i386 i386linux elf_l1om elf_k1om"
-                       targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
-                       tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
-                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
-i[3-7]86-*-sysv[45]*)  targ_emul=elf_i386 ;;
+                       targ64_extra_libpath="elf_x86_64 elf32_x86_64"
+                       ;;
+i[3-7]86-*-redox*)     targ_emul=elf_i386
+                       targ_extra_emuls=elf_x86_64
+                       ;;
+i[3-7]86-*-sysv[45]*)  targ_emul=elf_i386
+                       targ_extra_emuls=elf_iamcu
+                       ;;
 i[3-7]86-*-solaris2*)  targ_emul=elf_i386_sol2
-                        targ_extra_emuls="elf_i386_ldso elf_i386 elf_x86_64_sol2 elf_x86_64 elf_l1om elf_k1om"
-                       targ_extra_libpath=$targ_extra_emuls
-                        ;;
-x86_64-*-solaris2*)
-                       targ_emul=elf_x86_64_sol2
-                       targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_l1om elf_k1om"
+                       targ_extra_emuls="elf_i386_ldso elf_i386 elf_iamcu elf_x86_64_sol2 elf_x86_64 elf_l1om elf_k1om"
                        targ_extra_libpath=$targ_extra_emuls
-                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
-i[3-7]86-*-unixware)   targ_emul=elf_i386 ;;
+                       ;;
+i[3-7]86-*-unixware)   targ_emul=elf_i386
+                       targ_extra_emuls=elf_iamcu
+                       ;;
 i[3-7]86-*-solaris*)   targ_emul=elf_i386_ldso
-                        targ_extra_emuls="elf_i386"
+                       targ_extra_emuls="elf_i386"
                        targ_extra_libpath=$targ_extra_emuls
-                        ;;
+                       ;;
 i[3-7]86-*-netbsdelf* | \
 i[3-7]86-*-netbsd*-gnu* | \
 i[3-7]86-*-knetbsd*-gnu)
                        targ_emul=elf_i386
-                       targ_extra_emuls=i386nbsd ;;
+                       targ_extra_emuls="elf_iamcu"
+                       ;;
 i[3-7]86-*-netbsdpe*)  targ_emul=i386pe
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-i[3-7]86-*-netbsd*)    targ_emul=i386nbsd
-                       targ_extra_emuls=elf_i386 ;;
-x86_64-*-netbsd*)      targ_emul=elf_x86_64
-                       targ_extra_emuls="elf_i386 i386nbsd elf_l1om elf_k1om"
-                       tdir_elf_i386=`echo ${targ_alias} | \
-                           sed -e 's/x86_64/i386/'`
-                       case "${tdir_elf_i386}" in
-                       *-netbsdelf*)   ;;
-                       *)              tdir_elf_i386=`echo ${tdir_elf_i386} | \
-                                       sed -e 's/netbsd/netbsdelf/'`;;
-                       esac ;;
-i[3-7]86-*-netware)    targ_emul=i386nw ;;
-i[3-7]86-*-elf*)       targ_emul=elf_i386 ;;
-x86_64-*-elf*)         targ_emul=elf_x86_64
-                       targ_extra_emuls="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
-                       targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
-                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
+i[3-7]86-*-elfiamcu)   targ_emul=elf_iamcu
+                       targ_extra_emuls=elf_i386
+                       ;;
+i[3-7]86-*-elf* | i[3-7]86-*-rtems*)
+                       targ_emul=elf_i386
+                       targ_extra_emuls=elf_iamcu
                        ;;
-i[3-7]86-*-kaos*)      targ_emul=elf_i386 ;;
-i[3-7]86-*-freebsdaout* | i[3-7]86-*-freebsd[12].* | i[3-7]86-*-freebsd[12])
-                       targ_emul=i386bsd ;;
 i[3-7]86-*-dragonfly*) targ_emul=elf_i386
-                       targ_extra_emuls="i386bsd" ;;
-x86_64-*-dragonfly*)   targ_emul=elf_x86_64
-                       targ_extra_emuls="elf_i386 elf_l1om elf_k1om" ;;
+                       targ_extra_emuls="elf_iamcu i386bsd"
+                       ;;
 i[3-7]86-*-freebsd* | i[3-7]86-*-kfreebsd*-gnu)
-                       targ_emul=elf_i386_fbsd
-                       targ_extra_emuls="elf_i386 i386bsd" ;;
-x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
-                       targ_emul=elf_x86_64_fbsd
-                       targ_extra_emuls="elf_i386_fbsd elf_x86_64 elf_i386 elf_l1om elf_l1om_fbsd elf_k1om elf_k1om_fbsd"
-                       targ_extra_libpath="elf_i386_fbsd"
-                       tdir_elf_i386_fbsd=`echo ${targ_alias} \
-                           | sed -e 's/x86_64/i386/'`
-                       tdir_elf_i386=`echo ${targ_alias} \
-                           | sed -e 's/x86_64/i386/'` ;;
-i[3-7]86-*-sysv*)      targ_emul=i386coff ;;
-i[3-7]86-*-ptx*)       targ_emul=i386coff ;;
-i[3-7]86-*-mach*)      targ_emul=i386mach ;;
-i[3-7]86-*-gnu*)       targ_emul=elf_i386 ;;
-i[3-7]86-*-msdos*)     targ_emul=i386msdos; targ_extra_emuls=i386aout ;;
-i[3-7]86-*-moss*)      targ_emul=i386moss; targ_extra_emuls=i386msdos ;;
+                       targ_emul=elf_i386_fbsd
+                       targ_extra_emuls="elf_i386 elf_iamcu i386bsd"
+                       ;;
+i[3-7]86-*-gnu*)       targ_emul=elf_i386
+                       targ_extra_emuls=elf_iamcu
+                       ;;
+i[3-7]86-*-msdos*)     targ_emul=i386msdos
+                       targ_extra_emuls=i386aout
+                       targ_extra_ofiles=
+                       ;;
+i[3-7]86-*-moss*)      targ_emul=i386moss
+                       targ_extra_emuls=i386msdos
+                       targ_extra_ofiles=
+                       ;;
 i[3-7]86-*-winnt*)     targ_emul=i386pe ;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
 i[3-7]86-*-pe)         targ_emul=i386pe ;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-i[3-7]86-*-cygwin*)    targ_emul=i386pe ;
                        targ_extra_ofiles="deffilep.o pe-dll.o"
-                       test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api' ;;
+                       ;;
+i[3-7]86-*-cygwin*)    targ_emul=i386pe ;
+                       targ_extra_ofiles="deffilep.o pe-dll.o" ;
+                       test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api'
+                       ;;
 i[3-7]86-*-mingw32*)   targ_emul=i386pe ;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
-                       targ_extra_emuls=i386pe ;
-                       targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" ;;
-x86_64-*-cygwin)       targ_emul=i386pep ;
-                       targ_extra_emuls=i386pe
-                       targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
-                       test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api' ;;
-x86_64-*-mingw*)       targ_emul=i386pep ;
-                       targ_extra_emuls=i386pe
-                       targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" ;;
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
 i[3-7]86-*-interix*)   targ_emul=i386pe_posix;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-i[3-7]86-*-beospe*)    targ_emul=i386beos ;;
-i[3-7]86-*-beos*)      targ_emul=elf_i386_be ;;
-i[3-7]86-*-vxworks*)   targ_emul=elf_i386_vxworks ;;
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
+i[3-7]86-*-beospe*)    targ_emul=i386beos
+                       targ_extra_ofiles=
+                       ;;
+i[3-7]86-*-beos*)      targ_emul=elf_i386_be
+                       ;;
+i[3-7]86-*-vxworks*)   targ_emul=elf_i386_vxworks
+                       ;;
 i[3-7]86-*-chaos)      targ_emul=elf_i386_chaos
                        ;;
 i[3-7]86-*-nacl*)      targ_emul=elf_i386_nacl
@@ -338,90 +410,66 @@ i[3-7]86-*-nacl*) targ_emul=elf_i386_nacl
                        targ64_extra_emuls="elf32_x86_64_nacl elf_x86_64_nacl"
                        targ64_extra_libpath=$targ64_extra_emuls
                        ;;
-x86_64-*-nacl*)                targ_emul=elf32_x86_64_nacl
-                       targ_extra_emuls="elf_i386_nacl elf_x86_64_nacl armelf_nacl armelfb_nacl"
-                       targ_extra_libpath=$targ_extra_emuls
-                       tdir_elf_i386_nacl=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
-                       ;;
-i860-*-coff)           targ_emul=coff_i860 ;;
-i860-stardent-sysv4* | i860-stardent-elf*)
-                       targ_emul=elf32_i860
+ia16-*-elf*)           targ_emul=elf_i386
+                       targ_extra_emuls=i386msdos
                        ;;
-i960-wrs-vxworks5.0*)  targ_emul=gld960 ;;
-i960-wrs-vxworks5*)    targ_emul=gld960coff ;;
-i960-wrs-vxworks*)     targ_emul=gld960 ;;
-i960-*-coff)           targ_emul=gld960coff ;;
-i960-intel-nindy)      targ_emul=gld960 ;;
-i960-*-rtems*)         targ_emul=gld960coff ;;
-i960-*-elf*)           targ_emul=elf32_i960
+ia64-*-elf*)           targ_emul=elf64_ia64
                        ;;
-ia64-*-elf*)           targ_emul=elf64_ia64 ;;
 ia64-*-freebsd* | ia64-*-kfreebsd*-gnu)
-                       targ_emul=elf64_ia64_fbsd
-                       targ_extra_emuls="elf64_ia64" ;;
-ia64-*-netbsd*)                targ_emul=elf64_ia64 ;;
-ia64-*-linux*)         targ_emul=elf64_ia64 ;;
-ia64-*-*vms*)          targ_emul=elf64_ia64_vms ;;
+                       targ_emul=elf64_ia64_fbsd
+                       targ_extra_emuls="elf64_ia64"
+                       ;;
+ia64-*-netbsd*)                targ_emul=elf64_ia64
+                       ;;
+ia64-*-linux*)         targ_emul=elf64_ia64
+                       ;;
+ia64-*-*vms*)          targ_emul=elf64_ia64_vms
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
 ia64-*-aix*)           targ_emul=elf64_aix
                        ;;
 ip2k-*-elf)            targ_emul=elf32ip2k
                        ;;
-iq2000-*-elf)           targ_emul=elf32iq2000 ; targ_extra_emuls="elf32iq10"
+iq2000-*-elf)          targ_emul=elf32iq2000
+                       targ_extra_emuls="elf32iq10"
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
+lm32-*-*linux*)                targ_emul=elf32lm32fd
+                       ;;
+lm32-*-*)              targ_emul=elf32lm32
+                       targ_extra_emuls="elf32lm32fd"
                        ;;
-lm32-*-*linux*)         targ_emul=elf32lm32fd ;;
-lm32-*-*)               targ_emul=elf32lm32 ; targ_extra_emuls="elf32lm32fd"
-                        ;;
 m32c-*-elf | m32c-*-rtems*)
                        targ_emul=elf32m32c
                        ;;
-m32r*le-*-elf*)         targ_emul=m32rlelf ;;
+m32r*le-*-elf*)                targ_emul=m32rlelf
+                       ;;
 m32r*-*-elf* | m32r*-*-rtems*)
-                       targ_emul=m32relf ;;
-m32r*le-*-linux-*)      targ_emul=m32rlelf_linux ;;
-m32r*-*-linux-*)        targ_emul=m32relf_linux
+                       targ_emul=m32relf
+                       ;;
+m32r*le-*-linux-*)     targ_emul=m32rlelf_linux
+                       ;;
+m32r*-*-linux-*)       targ_emul=m32relf_linux
                        ;;
 m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
-                       targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb" ;;
+                       targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb"
+                       ;;
 m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
-                       targ_extra_emuls="m68hc12elfb m68hc11elf m68hc11elfb" ;;
-m68*-sun-sunos[34]*)   targ_emul=sun3 ;;
-m68*-wrs-vxworks*)     targ_emul=sun3 ;;
-m68*-ericsson-ose)     targ_emul=sun3 ;;
-m68*-apple-aux*)       targ_emul=m68kaux ;;
-m68k-sony-*)           targ_emul=news ;;
-m68k-hp-bsd*)          targ_emul=hp300bsd ;;
-m68*-motorola-sysv*)   targ_emul=delta68 ;;
-m68*-*-aout)           targ_emul=m68kaout ;;
-m68*-*-coff)           targ_emul=m68kcoff ;;
-m68*-*-elf)            targ_emul=m68kelf ;;
-m68*-*-hpux*)          targ_emul=hp3hpux ;;
-m68k-*-linux*aout*)    targ_emul=m68klinux
-                       targ_extra_emuls=m68kelf
-                       tdir_m68kelf=`echo ${targ_alias} | sed -e 's/aout//'` ;;
-m68k-*-linux-*)        targ_emul=m68kelf
-                       targ_extra_emuls=m68klinux
-                       tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'` ;;
-m68k-*-uclinux*)       targ_emul=m68kelf ;;
-m68*-*-gnu*)           targ_emul=m68kelf ;;
-m68*-*-netbsd*4k*)     targ_emul=m68k4knbsd
-                       targ_extra_emuls="m68knbsd m68kelfnbsd" ;;
+                       targ_extra_emuls="m68hc12elfb m68hc11elf m68hc11elfb"
+                       ;;
 m68*-*-netbsdelf*)     targ_emul=m68kelfnbsd
-                       targ_extra_emuls="m68knbsd m68k4knbsd" ;;
-m68*-*-netbsdaout* | m68*-*-netbsd*)
-                       targ_emul=m68knbsd
-                       targ_extra_emuls="m68kelfnbsd m68k4knbsd" ;;
-m68*-*-psos*)          targ_emul=m68kpsos ;;
-m68*-*-rtemscoff*)     targ_emul=m68kcoff ;;
-m68*-*-rtems*)         targ_emul=m68kelf
                        ;;
-m8*-*-*)               targ_emul=m88kbcs
+m68*-*-*)              targ_emul=m68kelf
                        ;;
 mcore-*-pe)            targ_emul=mcorepe ;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
 mcore-*-elf)           targ_emul=elf32mcore
                        ;;
-mep-*-elf)             targ_emul=elf32mep ;;
-metag-*-*)             targ_emul=elf32metag ;;
+mep-*-elf)             targ_emul=elf32mep
+                       ;;
+metag-*-*)             targ_emul=elf32metag
+                       ;;
 microblazeel*-linux*)  targ_emul="elf32mbel_linux"
                        targ_extra_emuls="elf32mb_linux"
                        ;;
@@ -434,112 +482,163 @@ microblazeel*)          targ_emul=elf32microblazeel
 microblaze*)           targ_emul=elf32microblaze
                        targ_extra_emuls=elf32microblazeel
                        ;;
-mips*-*-pe)            targ_emul=mipspe ;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-mips*-dec-ultrix*)     targ_emul=mipslit ;;
-mips*-dec-osf*)                targ_emul=mipslit ;;
-mips*-sgi-irix5*)      targ_emul=elf32bsmip ;;
+mips*-sgi-irix5*)      targ_emul=elf32bsmip
+                       ;;
 mips*-sgi-irix6*)      targ_emul=elf32bmipn32
-                       targ_extra_emuls="elf32bsmip elf64bmip"
-                       targ_extra_libpath=$targ_extra_emuls ;;
-mips*-sgi-irix*)       targ_emul=mipsbig ;;
-mips*el-*-ecoff*)      targ_emul=mipsidtl ;;
-mips*-*-ecoff*)                targ_emul=mipsidt ;;
+                       targ_extra_emuls="elf32bsmip elf64bmip"
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips*el-*-netbsd*)     targ_emul=elf32ltsmip
                        targ_extra_emuls="elf32btsmip elf64ltsmip elf64btsmip"
                        ;;
 mips*-*-netbsd*)       targ_emul=elf32btsmip
                        targ_extra_emuls="elf32ltsmip elf64btsmip elf64ltsmip"
-                       ;;
-mips*-*-bsd*)          targ_emul=mipsbig ;;
-mips*vr4300el-*-elf*)  targ_emul=elf32l4300 ;;
-mips*vr4300-*-elf*)    targ_emul=elf32b4300 ;;
-mips*vr4100el-*-elf*)  targ_emul=elf32l4300 ;;
-mips*vr4100-*-elf*)    targ_emul=elf32b4300 ;;
-mips*vr5000el-*-elf*)  targ_emul=elf32l4300 ;;
-mips*vr5000-*-elf*)    targ_emul=elf32b4300 ;;
-mips*el-sde-elf*)      targ_emul=elf32ltsmip
-                       targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip" ;;
-mips*-sde-elf* | mips*-mti-elf*)
+                       ;;
+mips64el-*-openbsd*)   targ_emul=elf64ltsmip
+                       targ_extra_emuls=elf64btsmip
+                       ;;
+mips64-*-openbsd*)     targ_emul=elf64btsmip
+                       targ_extra_emuls=elf64ltsmip
+                       ;;
+mips*vr4300el-*-elf*)  targ_emul=elf32l4300
+                       ;;
+mips*vr4300-*-elf*)    targ_emul=elf32b4300
+                       ;;
+mips*vr4100el-*-elf*)  targ_emul=elf32l4300
+                       ;;
+mips*vr4100-*-elf*)    targ_emul=elf32b4300
+                       ;;
+mips*vr5000el-*-elf*)  targ_emul=elf32l4300
+                       ;;
+mips*vr5000-*-elf*)    targ_emul=elf32b4300
+                       ;;
+mips*el-sde-elf* | mips*el-mti-elf* | mips*el-img-elf*)
+                       targ_emul=elf32ltsmip
+                       targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
+                       ;;
+mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
                        targ_emul=elf32btsmip
-                       targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip" ;;
+                       targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
+                       ;;
 mips64*el-ps2-elf*)    targ_emul=elf32lr5900n32
                        targ_extra_emuls="elf32lr5900"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips*el-ps2-elf*)      targ_emul=elf32lr5900
                        targ_extra_emuls="elf32lr5900n32"
-                       targ_extra_libpath=$targ_extra_emuls ;;
-mips*el-*-elf*)                targ_emul=elf32elmip ;;
-mips*-*-elf*)          targ_emul=elf32ebmip ;;
-mips*-*-rtems*)                targ_emul=elf32ebmip ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+mips*el-*-elf*)                targ_emul=elf32elmip
+                       ;;
+mips*-*-elf* | mips*-*-rtems*)
+                       targ_emul=elf32ebmip
+                       ;;
 mips*el-*-vxworks*)    targ_emul=elf32elmipvxworks
-                       targ_extra_emuls="elf32ebmipvxworks" ;;
+                       targ_extra_emuls="elf32ebmipvxworks"
+                       ;;
 mips*-*-vxworks*)      targ_emul=elf32ebmipvxworks
-                       targ_extra_emuls="elf32elmipvxworks" ;;
-mips*-*-windiss)       targ_emul=elf32mipswindiss ;;
+                       targ_extra_emuls="elf32elmipvxworks"
+                       ;;
+mips*-*-windiss)       targ_emul=elf32mipswindiss
+                       ;;
 mips64*el-*-linux-*)   targ_emul=elf32ltsmipn32
                        targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips64*-*-linux-*)     targ_emul=elf32btsmipn32
                        targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips*el-*-linux-*)     targ_emul=elf32ltsmip
                        targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips*-*-linux-*)       targ_emul=elf32btsmip
                        targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips64*el-*-freebsd* | mips64*el-*-kfreebsd*-gnu)
                        targ_emul=elf32ltsmipn32_fbsd
                        targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmip_fbsd elf32btsmip_fbsd elf32btsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips64*-*-freebsd* | mips64*-*-kfreebsd*-gnu)
                        targ_emul=elf32btsmipn32_fbsd
                        targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmip_fbsd elf32btsmip_fbsd elf32ltsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips*el-*-freebsd* | mips*el-*-kfreebsd*-gnu)
                        targ_emul=elf32ltsmip_fbsd
                        targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmipn32_fbsd elf32btsmip_fbsd elf32btsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 mips*-*-freebsd* | mips*-*-kfreebsd*-gnu)
                        targ_emul=elf32btsmip_fbsd
                        targ_extra_emuls="elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32 elf64ltsmip elf64btsmip elf32ltsmip_fbsd elf32btsmipn32_fbsd elf32ltsmipn32_fbsd elf64ltsmip_fbsd elf64btsmip_fbsd"
-                       targ_extra_libpath=$targ_extra_emuls ;;
-mips*-*-lnews*)                targ_emul=mipslnews ;;
-mips*-*-sysv4*)         targ_emul=elf32btsmip
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+mips*-*-sysv4*)                targ_emul=elf32btsmip
                        ;;
 mmix-*-*)              targ_emul=mmo
                        targ_extra_emuls=elf64mmix
                        ;;
-am34-*-linux*)         targ_emul=elf32am33lin ;;
-am33_2.0-*-linux*)     targ_emul=elf32am33lin ;;
-mn10200-*-*)           targ_emul=mn10200 ;;
+mn10200-*-*)           targ_emul=mn10200
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
 mn10300-*-*)           targ_emul=mn10300
                        ;;
-mt-*elf)                targ_emul=elf32mt
+moxie-*-moxiebox*)     targ_emul=moxiebox
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
+moxie-*-*)             targ_emul=elf32moxie
+                       ;;
+msp430-*-*)            targ_emul=msp430elf
+                       targ_extra_emuls="msp430X"
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
+mt-*elf)               targ_emul=elf32mt
+                       targ_extra_ofiles=ldelfgen.o
                        ;;
-msp430-*-*)             targ_emul=msp430x110
-                        targ_extra_emuls="msp430x112 msp430x1101 msp430x1111 msp430x1121 msp430x1122 msp430x1132 msp430x122 msp430x123 msp430x1222 msp430x1232 msp430x133 msp430x135 msp430x1331 msp430x1351 msp430x147 msp430x148 msp430x149 msp430x155 msp430x156 msp430x157 msp430x167 msp430x168 msp430x169 msp430x1610 msp430x1611 msp430x1612 msp430x2101 msp430x2111 msp430x2121 msp430x2131 msp430x311 msp430x312 msp430x313 msp430x314 msp430x315 msp430x323 msp430x325 msp430x336 msp430x337 msp430x412 msp430x413 msp430x415 msp430x417 msp430xE423 msp430xE425 msp430xE427 msp430xW423 msp430xW425 msp430xW427 msp430xG437 msp430xG438 msp430xG439 msp430x435 msp430x436 msp430x437 msp430x447 msp430x448 msp430x449 msp430X"
+nds32*le-*-elf*)       targ_emul=nds32elf
+                       targ_extra_emuls="nds32elf16m nds32belf nds32belf16m"
+                       ;;
+nds32*be-*-elf*)       targ_emul=nds32belf
+                       targ_extra_emuls="nds32elf nds32elf16m nds32belf16m"
+                       ;;
+nds32*le-*-linux-gnu*) targ_emul=nds32elf_linux
+                       ;;
+nds32*be-*-linux-gnu*) targ_emul=nds32belf_linux
+                       ;;
+nios2*-*-linux*)       targ_emul=nios2linux
+                       ;;
+nios2*-*-*)            targ_emul=nios2elf
+                       ;;
+ns32k-pc532-mach* | ns32k-pc532-ux*)  targ_emul=pc532macha
+                       targ_extra_ofiles=
                        ;;
-nios2*-*-*)            targ_emul=nios2elf ;;
-ns32k-pc532-mach* | ns32k-pc532-ux*)  targ_emul=pc532macha ;;
 ns32k-*-netbsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd
+                       targ_extra_ofiles=
                        ;;
-openrisc-*-*)          targ_emul=elf32openrisc ;;
-or32-*-coff)           targ_emul=or32 ;;
-or32-*-elf)            targ_emul=or32elf ;;
-or32-*-rtems*)          targ_emul=or32elf
+or1k-*-elf | or1knd-*-elf | or1k-*-rtems* | or1knd-*-rtems*)
+                       targ_emul=elf32or1k
+                       ;;
+or1k-*-linux* | or1knd-*-linux*)       targ_emul=elf32or1k_linux
                        ;;
 pdp11-*-*)             targ_emul=pdp11
+                       targ_extra_ofiles=
+                       ;;
+pjl*-*-*)              targ_emul=pjlelf
+                       targ_extra_emuls="elf_i386 elf_iamcu"
                        ;;
-pjl*-*-*)              targ_emul=pjlelf ; targ_extra_emuls="elf_i386" ;;
-pj*-*-*)               targ_emul=pjelf
+pj*-*-*)               targ_emul=pjelf
+                       targ_extra_ofiles=ldelfgen.o
                        ;;
 powerpc-*-freebsd* | powerpc-*-kfreebsd*-gnu)
                        targ_emul=elf32ppc_fbsd
                        targ_extra_emuls="elf32ppc elf32ppcsim"
                        targ_extra_libpath=elf32ppc;
-                       tdir_elf32ppcsim=`echo ${targ_alias} | sed -e 's/ppc/ppcsim/'` ;;
+                       tdir_elf32ppcsim=`echo ${targ_alias} | sed -e 's/ppc/ppcsim/'`
+                       ;;
 powerpc64-*-freebsd*)
                        targ_emul=elf64ppc_fbsd
                        targ_extra_emuls="elf64ppc elf32ppc_fbsd elf32ppc"
@@ -549,178 +648,250 @@ powerpc64-*-freebsd*)
                        ;;
 powerpc-*-vxworks*)
                        targ_emul=elf32ppcvxworks
-                       targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim" ;;
+                       targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim"
+                       ;;
 powerpc*-*-elf* | powerpc*-*-eabi* | powerpc*-*-sysv* \
   | powerpc*-*-linux* | powerpc*-*-netbsd* | powerpc*-*-openbsd* \
+  | powerpc*-*-rtems* \
   | powerpc*-*-solaris* | powerpc*-*-kaos* | powerpc*-*-vxworks*)
                        case "${targ}" in
-                       *64*)   targ_emul=elf64ppc
-                               targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim"
-                               targ_extra_libpath="elf32ppc elf32ppclinux"
-                               td=tdir_elf32ppc
-                               case "${targ}" in
-                               powerpc*le-*) td=tdir_elf32lppc;;
-                               esac
-                               eval ${td}=`echo "${targ_alias}" | sed -e 's/64//'`
-                               eval ${td}linux=\$${td}
-                               eval ${td}sim=\$${td}
-                               ;;
-                       *linux*) targ_emul=elf32ppclinux
-                               targ_extra_emuls="elf32ppc elf32ppcsim"
-                               targ_extra_libpath=elf32ppc
-                               targ64_extra_emuls=elf64ppc
-                               targ64_extra_libpath=elf64ppc
-                               ;;
-                       *)      targ_emul=elf32ppc
-                               targ_extra_emuls="elf32ppclinux elf32ppcsim"
-                               targ_extra_libpath=elf32ppclinux
-                               targ64_extra_emuls=elf64ppc
-                               targ64_extra_libpath=elf64ppc
-                               ;;
+                       powerpc64*)
+                           targ_emul=elf64ppc
+                           targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim"
+                           targ_extra_libpath="elf32ppc elf32ppclinux" ;;
+                       *linux*)
+                           targ_emul=elf32ppclinux
+                           targ_extra_emuls="elf32ppc elf32ppcsim"
+                           targ_extra_libpath=elf32ppc
+                           targ64_extra_emuls=elf64ppc
+                           targ64_extra_libpath=elf64ppc ;;
+                       *)
+                           targ_emul=elf32ppc
+                           targ_extra_emuls="elf32ppclinux elf32ppcsim"
+                           targ_extra_libpath=elf32ppclinux
+                           targ64_extra_emuls=elf64ppc
+                           targ64_extra_libpath=elf64ppc ;;
+                       esac
+                       td=tdir_elf32ppc
+                       td64=tdir_elf64ppc
+                       s=s/ppc/lppc/g
+                       case "${targ}" in
+                       powerpcle-* | powerpc64le-*)
+                           for z in td td64 targ_emul targ_extra_emuls \
+                                        targ_extra_libpath targ64_extra_emuls \
+                                        targ64_extra_libpath
+                           do
+                               eval ${z}=\"\`echo \$${z} \| sed -e $s\`\"
+                           done
+                           s=s/lppc/ppc/g ;;
+                       esac
+                       # Why oh why did we set tooldir based on target_alias
+                       # rather than on target?
+                       eval tdir_${targ_emul}="${targ_alias}"
+                       cpu=`echo "${targ_alias}" | sed -e 's/-.*//'`
+                       rest=`echo "${targ_alias}" | sed -e 's/^[^-]*//'`
+                       le=le
+                       case "${cpu}" in
+                       *little) le=little
                        esac
+                       ta32=`echo "${cpu}" | sed -e s/64//`"${rest}"
+                       ta64=`echo "${cpu}" | sed -e 's/64//;s/$/64/;s/'${le}'64$/64'${le}'/;s/be64$/64be/'`"${rest}"
+                       eval test -n \"\$${td}\" || eval ${td}="${ta32}"
+                       eval test -n \"\$${td}linux\" || eval ${td}linux="${ta32}"
+                       eval test -n \"\$${td}sim\" || eval ${td}sim="${ta32}"
+                       eval test -n \"\$${td64}\" || eval ${td64}="${ta64}"
+                       # Now provide the other endian
+                       for z in targ_extra_emuls targ_extra_libpath
+                       do
+                           eval ${z}=\"\$${z} \`echo ${targ_emul} \$${z} \| sed -e $s\`\"
+                       done
+                       for z in targ64_extra_emuls targ64_extra_libpath
+                       do
+                           eval ${z}=\"\$${z} \`echo \$${z} \| sed -e $s\`\"
+                       done
+                       td=`echo "${td}" | sed -e $s`
+                       td64=`echo "${td64}" | sed -e $s`
                        case "${targ}" in
-                       powerpc*le-*)
-                               for z in targ_emul targ_extra_emuls targ_extra_libpath targ64_extra_emuls targ64_extra_libpath
-                               do
-                                 eval ${z}=\"`eval echo \\$${z} | sed -e 's/ppc/lppc/g'`\"
-                               done
-                       esac ;;
-powerpc-*-nto*)         targ_emul=elf32ppcnto ;;
-powerpcle-*-nto*)       targ_emul=elf32lppcnto ;;
-powerpc-*-rtems*)      targ_emul=elf32ppc ;;
-powerpc-*-macos*)      targ_emul=ppcmacos ;;
-powerpc-*-netware*)    targ_emul=ppcnw ;;
+                       powerpcle-* | powerpc64le-*)
+                           cpu=`echo "${cpu}" | sed -e s/${le}\$//` ;;
+                       *)
+                           cpu=`echo "${cpu}" | sed -e s/be\$//`${le} ;;
+                       esac
+                       ta32=`echo "${cpu}" | sed -e s/64//`"${rest}"
+                       ta64=`echo "${cpu}" | sed -e 's/64//;s/$/64/;s/'${le}'64$/64'${le}/`"${rest}"
+                       eval test -n \"\$${td}\" || eval ${td}="${ta32}"
+                       eval test -n \"\$${td}linux\" || eval ${td}linux="${ta32}"
+                       eval test -n \"\$${td}sim\" || eval ${td}sim="${ta32}"
+                       eval test -n \"\$${td64}\" || eval ${td64}="${ta64}"
+                       ;;
+powerpc-*-nto*)                targ_emul=elf32ppcnto
+                       ;;
+powerpcle-*-nto*)      targ_emul=elf32lppcnto
+                       ;;
+powerpc-*-macos*)      targ_emul=ppcmacos
+                       targ_extra_ofiles=
+                       ;;
 powerpcle-*-pe | powerpcle-*-winnt* | powerpcle-*-cygwin*)
                        targ_emul=ppcpe
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-powerpc-*-aix[5-9]*)   targ_emul=aix5ppc ;;
-powerpc-*-aix*)                targ_emul=aixppc ;;
-powerpc-*-beos*)       targ_emul=aixppc ;;
-powerpc-*-windiss*)    targ_emul=elf32ppcwindiss ;;
-powerpc-*-lynxos*)     targ_emul=ppclynx ;;
-rs6000-*-aix[5-9]*)    targ_emul=aix5rs6 ;;
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
+powerpc-*-aix[5-9]*)   targ_emul=aix5ppc
+                       targ_extra_ofiles=
+                       ;;
+powerpc-*-aix*)                targ_emul=aixppc
+                       targ_extra_ofiles=
+                       ;;
+powerpc-*-beos*)       targ_emul=aixppc
+                       targ_extra_ofiles=
+                       ;;
+powerpc-*-windiss*)    targ_emul=elf32ppcwindiss
+                       ;;
+powerpc-*-lynxos*)     targ_emul=ppclynx
+                       ;;
+pru*-*-*)              targ_emul=pruelf
+                       ;;
+riscv32*-*-linux*)     targ_emul=elf32lriscv
+                       targ_extra_emuls="elf32lriscv_ilp32f elf32lriscv_ilp32 elf64lriscv elf64lriscv_lp64f elf64lriscv_lp64"
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+riscv-*-* | riscv32*-*-*)
+                       targ_emul=elf32lriscv
+                       targ_extra_emuls="elf64lriscv"
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+riscv64*-*-linux*)     targ_emul=elf64lriscv
+                       targ_extra_emuls="elf64lriscv_lp64f elf64lriscv_lp64 elf32lriscv elf32lriscv_ilp32f elf32lriscv_ilp32"
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+riscv64*-*-*)          targ_emul=elf64lriscv
+                       targ_extra_emuls="elf32lriscv"
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+rs6000-*-aix[5-9]*)    targ_emul=aix5rs6
+                       targ_extra_ofiles=
+                       ;;
 rs6000-*-aix*)         targ_emul=aixrs6
+                       targ_extra_ofiles=
+                       ;;
+rl78-*-*)              targ_emul=elf32rl78
                        ;;
-rl78-*-*)              targ_emul=elf32rl78 ;;
-rx-*-*)                        targ_emul=elf32rx ;;
-s390x-*-linux*)         targ_emul=elf64_s390
+rx-*-*)                        targ_emul=elf32rx
+                       ;;
+s12z-*-*)              targ_emul=m9s12zelf
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
+s390x-*-linux*)                targ_emul=elf64_s390
                        targ_extra_emuls=elf_s390
                        targ_extra_libpath=$targ_extra_emuls
-                       tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;;
+                       tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'`
+                       ;;
 s390x-*-tpf*)          targ_emul=elf64_s390
-                       tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;;
-s390-*-linux*)          targ_emul=elf_s390
+                       tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'`
+                       ;;
+s390-*-linux*)         targ_emul=elf_s390
                        targ64_extra_emuls=elf64_s390
                        targ64_extra_libpath=elf64_s390
                        tdir_elf64_s390=`echo ${targ_alias} | sed -e 's/s390/s390x/'`
                        ;;
-score-*-elf)            targ_emul=score7_elf
-                       targ_extra_emuls=score3_elf ;;
+score-*-elf)           targ_emul=score7_elf
+                       targ_extra_emuls=score3_elf
+                       ;;
 sh-*-linux*)           targ_emul=shlelf_linux
-                       targ_extra_emuls=shelf_linux
-                       targ_extra_libpath=shelf_linux ;;
-sh64eb-*-linux*)       targ_emul=shelf32_linux
-                       targ_extra_emuls="shlelf32_linux" ;;
-sh64-*-linux*)         targ_emul=shlelf32_linux
-                       targ_extra_emuls="shelf32_linux"
-                       targ_extra_libpath=shelf32_linux ;;
-sh*eb-*-linux*)                targ_emul=shelf_linux ;;
-sh*-*-linux*)          targ_emul=shlelf_linux ;;
-sh5le-*-netbsd*)       targ_emul=shlelf32_nbsd
-                       targ_extra_emuls="shelf32_nbsd shelf64_nbsd shlelf64_nbsd shelf_nbsd shlelf_nbsd" ;;
-sh5-*-netbsd*)         targ_emul=shelf32_nbsd
-                       targ_extra_emuls="shlelf32_nbsd shelf64_nbsd shlelf64_nbsd shelf_nbsd shlelf_nbsd" ;;
-sh64le-*-netbsd*)      targ_emul=shlelf64_nbsd
-                       targ_extra_emuls="shelf64_nbsd shelf32_nbsd shlelf32_nbsd shelf_nbsd shlelf_nbsd" ;;
-sh64-*-netbsd*)                targ_emul=shelf64_nbsd
-                       targ_extra_emuls="shlelf64_nbsd shelf32_nbsd shlelf32_nbsd shelf_nbsd shlelf_nbsd" ;;
+                       targ_extra_emuls="shelf_linux shlelf_fd shelf_fd"
+                       targ_extra_libpath=shelf_linux
+                       ;;
+sh*eb-*-linux*)                targ_emul=shelf_linux
+                       targ_extra_emuls="shelf_fd"
+                       ;;
+sh*-*-linux*)          targ_emul=shlelf_linux
+                       targ_extra_emuls="shlelf_fd"
+                       ;;
 sh*l*-*-netbsdelf*)    targ_emul=shlelf_nbsd
-                       targ_extra_emuls=shelf_nbsd ;;
+                       targ_extra_emuls=shelf_nbsd
+                       ;;
 sh*-*-netbsdelf*)      targ_emul=shelf_nbsd
-                       targ_extra_emuls=shlelf_nbsd ;;
-sh*-*-symbianelf*)     targ_emul=shlsymbian ;;
+                       targ_extra_emuls=shlelf_nbsd
+                       ;;
 shle*-*-elf* | sh[1234]*le*-*-elf | shle*-*-kaos*)
                        targ_emul=shlelf
-                       targ_extra_emuls="shelf shl sh" ;;
-sh-*-rtemscoff*)       targ_emul=sh; targ_extra_emuls=shl ;;
+                       targ_extra_emuls="shelf shl sh"
+                       ;;
 sh-*-elf* | sh[1234]*-*-elf | sh-*-rtems* | sh-*-kaos*)
                        targ_emul=shelf
-                       targ_extra_emuls="shlelf sh shl" ;;
+                       targ_extra_emuls="shlelf sh shl"
+                       ;;
 sh-*-uclinux* | sh[12]-*-uclinux*)
                        targ_emul=shelf_uclinux
-                       targ_extra_emuls="shelf shlelf sh shl shelf_fd shlelf_fd" ;;
+                       targ_extra_emuls="shelf shlelf sh shl shelf_fd shlelf_fd"
+                       ;;
 sh-*-vxworks)          targ_emul=shelf_vxworks
-                       targ_extra_emuls=shlelf_vxworks ;;
+                       targ_extra_emuls=shlelf_vxworks
+                       ;;
 sh-*-nto*)             targ_emul=shelf_nto
-                       targ_extra_emuls=shlelf_nto ;;
+                       targ_extra_emuls=shlelf_nto
+                       ;;
 sh-*-pe)               targ_emul=shpe ;
-                       targ_extra_ofiles="deffilep.o pe-dll.o" ;;
-sh-*-*)                        targ_emul=sh; targ_extra_emuls=shl ;;
-sh64le-*-elf*)         targ_emul=shlelf
-                       targ_extra_emuls="shelf shlelf32 shelf32 shlelf64 shelf64"
-                       targ_extra_libpath=$targ_extra_emuls ;;
-sh64-*-elf*)           targ_emul=shelf
-                       targ_extra_emuls="shlelf shelf32 shlelf32 shelf64 shlelf64"
-                       targ_extra_libpath=$targ_extra_emuls ;;
-sparc64-*-aout*)       targ_emul=sparcaout ;;
-sparc64-*-elf*)                targ_emul=elf64_sparc ;;
-sparc64-*-rtems*)      targ_emul=elf64_sparc ;;
-sparc-sun-sunos4*)     targ_emul=sun4 ;;
-sparclite*-*-elf)      targ_emul=elf32_sparc ;;
-sparclite*-*-coff)     targ_emul=coff_sparc ;;
-sparclite*-fujitsu-*)  targ_emul=sparcaout ;;
-sparc*-*-aout)         targ_emul=sparcaout ;;
-sparc*-*-coff)         targ_emul=coff_sparc ;;
-sparc*-*-elf)          targ_emul=elf32_sparc ;;
-sparc*-*-sysv4*)       targ_emul=elf32_sparc ;;
-sparc*-*-vxworks*)     targ_emul=elf32_sparc_vxworks ;;
+                       targ_extra_ofiles="deffilep.o pe-dll.o"
+                       ;;
+sh-*-*)                        targ_emul=sh;
+                       targ_extra_emuls=shl
+                       targ_extra_ofiles=
+                       ;;
 sparc64-*-freebsd* | sparcv9-*-freebsd* | sparc64-*-kfreebsd*-gnu | sparcv9-*-kfreebsd*-gnu)
                        targ_emul=elf64_sparc_fbsd
                        targ_extra_emuls="elf64_sparc elf32_sparc"
                        targ_extra_libpath=$targ_extra_emuls
-                       tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'` ;;
-sparc*-*-linux*aout*)  targ_emul=sparclinux
-                       targ_extra_emuls="elf32_sparc sun4"
-                       tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/aout//'`
-                       tdir_sun4=sparc-sun-sunos4 ;;
+                       tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
+                       ;;
 sparc64-*-linux-*)     targ_emul=elf64_sparc
-                       targ_extra_emuls="elf32_sparc sparclinux sun4"
+                       targ_extra_emuls="elf32_sparc"
                        targ_extra_libpath=elf32_sparc
                        tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
-                       tdir_sparclinux=${tdir_elf32_sparc}aout
-                       tdir_sun4=sparc-sun-sunos4 ;;
+                       ;;
+sparc64-*-*bsd*)       targ_emul=elf64_sparc
+                       targ_extra_emuls="elf32_sparc"
+                       ;;
+sparc64-*-solaris2* | sparcv9-*-solaris2*)
+                       targ_emul=elf64_sparc_sol2
+                       targ_extra_emuls="elf64_sparc elf32_sparc_sol2 elf32_sparc"
+                       targ_extra_libpath=$targ_extra_emuls
+                       tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
+                       ;;
+sparc64-*-*)           targ_emul=elf64_sparc
+                       ;;
 sparc*-*-linux-*)      targ_emul=elf32_sparc
-                       targ_extra_emuls="sparclinux elf64_sparc sun4"
+                       targ_extra_emuls="elf64_sparc"
                        targ_extra_libpath=elf64_sparc
-                       tdir_sparclinux=${targ_alias}aout
                        tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'`
-                       tdir_sun4=sparc-sun-sunos4 ;;
-sparc64-*-netbsd* | sparc64-*-openbsd*)
-                       targ_emul=elf64_sparc
-                       targ_extra_emuls="elf32_sparc" ;;
-sparc*-*-netbsd*elf*)  targ_emul=elf32_sparc ;;
-sparc*-*-netbsd*)      targ_emul=sparcnbsd ;;
+                       ;;
 sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*)
                        targ_emul=elf32_sparc_sol2
-                       targ_extra_emuls=elf32_sparc ;;
+                       targ_extra_emuls=elf32_sparc
+                       ;;
 sparc-*-solaris2*)     targ_emul=elf32_sparc_sol2
                        targ_extra_emuls="elf32_sparc elf64_sparc_sol2 elf64_sparc"
                        targ_extra_libpath=$targ_extra_emuls
-                       tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'` ;;
-sparcv9-*-solaris2* | sparc64-*-solaris2*)
-                       targ_emul=elf64_sparc_sol2
-                       targ_extra_emuls="elf64_sparc elf32_sparc_sol2 elf32_sparc"
-                       targ_extra_libpath=$targ_extra_emuls
-                       tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'` ;;
-sparc*-*-solaris2*)    targ_emul=elf32_sparc ;;
-sparc*-wrs-vxworks*)   targ_emul=sparcaout ;;
-sparc-*-rtems*)                targ_emul=elf32_sparc
+                       tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'`
+                       ;;
+sparc*-*-vxworks*)     targ_emul=elf32_sparc_vxworks
+                       ;;
+sparc*-*-*)            targ_emul=elf32_sparc
+                       ;;
+spu-*-elf*)            targ_emul=elf32_spu
+                       ;;
+tic30-*-*aout*)                targ_emul=tic30aout
+                       targ_extra_ofiles=
+                       ;;
+tic30-*-*coff*)                targ_emul=tic30coff
+                       targ_extra_ofiles=
+                       ;;
+tic4x-*-* | c4x-*-*)   targ_emul=tic4xcoff
+                       targ_extra_emuls="tic3xcoff tic3xcoff_onchip"
+                       targ_extra_ofiles=
+                       ;;
+tic54x-*-* | c54x*-*-*)        targ_emul=tic54xcoff
+                       targ_extra_ofiles=
                        ;;
-spu-*-elf*)            targ_emul=elf32_spu ;;
-tic30-*-*aout*)                targ_emul=tic30aout ;;
-tic30-*-*coff*)                targ_emul=tic30coff ;;
-tic4x-*-* | c4x-*-*)    targ_emul=tic4xcoff ; targ_extra_emuls="tic3xcoff tic3xcoff_onchip" ;;
-tic54x-*-* | c54x*-*-*)        targ_emul=tic54xcoff ;;
 tic6x-*-elf)           targ_emul=elf32_tic6x_elf_le
                        targ_extra_emuls="elf32_tic6x_elf_be elf32_tic6x_le elf32_tic6x_be"
                        targ_extra_libpath=$targ_extra_emuls
@@ -729,44 +900,130 @@ tic6x-*-uclinux) targ_emul=elf32_tic6x_linux_le
                        targ_extra_emuls="elf32_tic6x_linux_be elf32_tic6x_le elf32_tic6x_be"
                        targ_extra_libpath=$targ_extra_emuls
                        ;;
-tic80-*-*)             targ_emul=tic80coff
-                       ;;
 tilegx-*-*)            targ_emul=elf64tilegx
                        targ_extra_emuls="elf64tilegx_be elf32tilegx elf32tilegx_be"
-                       targ_extra_libpath=$targ_extra_emuls ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
 tilegxbe-*-*)          targ_emul=elf64tilegx_be
                        targ_extra_emuls="elf64tilegx elf32tilegx elf32tilegx_be"
-                       targ_extra_libpath=$targ_extra_emuls ;;
-tilepro-*-*)           targ_emul=elf32tilepro ;;
+                       targ_extra_libpath=$targ_extra_emuls
+                       ;;
+tilepro-*-*)           targ_emul=elf32tilepro
+                       ;;
 v850*-*-*)             targ_emul=v850_rh850
                        targ_extra_emuls=v850
                        ;;
-vax-dec-ultrix* | vax-dec-bsd*) targ_emul=vax ;;
 vax-*-netbsdelf*)      targ_emul=elf32vax
-                       targ_extra_emuls=vaxnbsd ;;
+                       targ_extra_emuls=vaxnbsd
+                       ;;
 vax-*-netbsdaout* | vax-*-netbsd*)
                        targ_emul=vaxnbsd
-                       targ_extra_emuls=elf32vax ;;
-vax-*-linux-*)         targ_emul=elf32vax
+                       targ_extra_emuls=elf32vax
+                       ;;
+vax-*-linux-*)         targ_emul=elf32vax
+                       ;;
+visium-*-elf)          targ_emul=elf32visium
                        ;;
-w65-*-*)               targ_emul=w65
+x86_64-*-rdos*)                targ_emul=elf64rdos
+                       ;;
+x86_64-*-cloudabi*)    targ_emul=elf_x86_64_cloudabi
+                       ;;
+x86_64-*-linux-gnux32) targ_emul=elf32_x86_64
+                       targ_extra_emuls="elf_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om"
+                       targ_extra_libpath="elf_i386 elf_iamcu elf_x86_64 elf_l1om elf_k1om"
+                       tdir_elf_iamcu=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
+                       ;;
+x86_64-*-linux-*)      targ_emul=elf_x86_64
+                       targ_extra_emuls="elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om"
+                       targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
+                       ;;
+x86_64-*-redox*)       targ_emul=elf_x86_64
+                       targ_extra_emuls=elf_i386
+                       ;;
+x86_64-*-solaris2*)    targ_emul=elf_x86_64_sol2
+                       targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu elf_l1om elf_k1om"
+                       targ_extra_libpath=$targ_extra_emuls
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
+                       ;;
+x86_64-*-netbsd*)      targ_emul=elf_x86_64
+                       targ_extra_emuls="elf_i386 elf_iamcu elf_l1om elf_k1om"
+                       tdir_elf_iamcu=`echo ${targ_alias} | \
+                           sed -e 's/x86_64/i386/'`
+                       case "${tdir_elf_iamcu}" in
+                       *-netbsdelf*)   ;;
+                       *)              tdir_elf_iamcu=`echo ${tdir_elf_iamcu} | \
+                                       sed -e 's/netbsd/netbsdelf/'`;;
+                       esac
+                       tdir_elf_i386=`echo ${targ_alias} | \
+                           sed -e 's/x86_64/i386/'`
+                       case "${tdir_elf_i386}" in
+                       *-netbsdelf*)   ;;
+                       *)              tdir_elf_i386=`echo ${tdir_elf_i386} | \
+                                       sed -e 's/netbsd/netbsdelf/'`;;
+                       esac
+                       ;;
+x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia*)
+                       targ_emul=elf_x86_64
+                       targ_extra_emuls="elf_i386 elf_iamcu elf32_x86_64 elf_l1om elf_k1om"
+                       targ_extra_libpath="elf_i386 elf_iamcu elf32_x86_64 elf_l1om elf_k1om"
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
+                       ;;
+x86_64-*-dragonfly*)   targ_emul=elf_x86_64
+                       targ_extra_emuls="elf_i386 elf_iamcu elf_l1om elf_k1om"
+                       ;;
+x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
+                       targ_emul=elf_x86_64_fbsd
+                       targ_extra_emuls="elf_i386_fbsd elf_x86_64 elf_i386 elf_iamcu elf_l1om elf_l1om_fbsd elf_k1om elf_k1om_fbsd"
+                       targ_extra_libpath="elf_i386_fbsd"
+                       tdir_elf_i386_fbsd=`echo ${targ_alias} \
+                           | sed -e 's/x86_64/i386/'`
+                       tdir_elf_iamcu=`echo ${targ_alias} \
+                           | sed -e 's/x86_64/i386/'`
+                       tdir_elf_i386=`echo ${targ_alias} \
+                           | sed -e 's/x86_64/i386/'`
+                       ;;
+x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
+                       targ_extra_emuls=i386pe ;
+                       targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
+                       ;;
+x86_64-*-cygwin)       targ_emul=i386pep ;
+                       targ_extra_emuls=i386pe
+                       targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
+                       test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api'
+                       ;;
+x86_64-*-mingw*)       targ_emul=i386pep ;
+                       targ_extra_emuls=i386pe
+                       targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
+                       ;;
+x86_64-*-nacl*)                targ_emul=elf32_x86_64_nacl
+                       targ_extra_emuls="elf_i386_nacl elf_x86_64_nacl armelf_nacl armelfb_nacl"
+                       targ_extra_libpath=$targ_extra_emuls
+                       tdir_elf_i386_nacl=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
                        ;;
 xc16x-*-elf)           targ_emul=elf32xc16x
-                        targ_extra_emuls="elf32xc16xl elf32xc16xs"
-                        ;;
+                       targ_extra_emuls="elf32xc16xl elf32xc16xs"
+                       ;;
+xgate-*-*)             targ_emul=xgateelf
+                       targ_extra_ofiles=ldelfgen.o
+                       ;;
 xstormy16-*-*)         targ_emul=elf32xstormy16
                        ;;
 xtensa*-*-*)           targ_emul=elf32xtensa
                        ;;
-xgate-*-*)     targ_emul=xgateelf 
+z80-*-elf*)            targ_emul=elf32z80
+                       targ_extra_ofiles="ldelf.o ldelfgen.o"
                        ;;
 z80-*-coff)            targ_emul=z80
+                       targ_extra_ofiles=
                        ;;
-z8k-*-coff)            targ_emul=z8002; targ_extra_emuls=z8001
+z8k-*-coff)            targ_emul=z8002
+                       targ_extra_emuls=z8001
+                       targ_extra_ofiles=
                        ;;
 *-*-ieee*)             targ_emul=vanilla
-                       ;;
-*-tandem-none)         targ_emul=st2000
+                       targ_extra_ofiles=
                        ;;
 *)
   echo 2>&1 "*** ld does not support target ${targ}"
@@ -779,7 +1036,7 @@ NATIVE_LIB_DIRS='/usr/local/lib /lib /usr/lib'
 case "${target}" in
 
 *-*-dragonfly*)
-  NATIVE_LIB_DIRS='/usr/lib /usr/pkg/lib /usr/local/lib'
+  NATIVE_LIB_DIRS='/lib /usr/lib /usr/pkg/lib /usr/local/lib'
   ;;
 
 *-*-freebsd*)
@@ -830,3 +1087,37 @@ alpha*-*-*)
   ;;
 
 esac
+
+case "${target}" in
+frv-*-* | hppa*-*-* | ia64-*-* | mips*-*-*)
+  # Don't enable -z relro by default since many relro tests fail on these
+  # targets:
+  # FAIL: strip -z relro (relro1)
+  # FAIL: strip -z relro -shared (relro1)
+  # FAIL: objcopy -z relro (relro1)
+  # FAIL: objcopy -z relro -shared (relro1)
+  # FAIL: objcopy -z relro (tdata1)
+  # FAIL: objcopy -shared -z relro (tdata1)
+  # FAIL: objcopy -z relro (tdata2)
+  # FAIL: objcopy -shared -z relro (tdata2)
+  # FAIL: objcopy -z relro (tdata3)
+  # FAIL: objcopy -shared -z relro (tdata3)
+  # FAIL: objcopy -shared -z relro (tbss1)
+  # FAIL: objcopy -shared -z relro (tbss2)
+  # FAIL: objcopy -shared -z relro (tbss3)
+  ;;
+*-*-linux*)
+  if test ${ac_default_ld_z_relro} = unset; then
+    ac_default_ld_z_relro=1
+  fi
+  ;;
+esac
+
+# Enable -z separate-code by default for Linux/x86.
+case "${target}" in
+i[3-7]86-*-linux-* | x86_64-*-linux-*)
+  if test ${ac_default_ld_z_separate_code} = unset; then
+    ac_default_ld_z_separate_code=1
+  fi
+  ;;
+esac