From fa35de75a81dc38986949a090f3b08dd32effba3 Mon Sep 17 00:00:00 2001
From: yeqinglong <yeqinglong@kylinsec.com.cn>
Date: Wed, 30 Aug 2023 15:01:58 +0800
Subject: [PATCH] add sw_64 support not upstream modified files

---
 Makefile.in                                 |   1 +
 Makefile.tpl                                |   1 +
 bfd/Makefile.am                             |  12 ++-
 bfd/Makefile.in                             |  16 ++-
 bfd/archures.c                              |  12 +++
 bfd/bfd-in2.h                               | 109 ++++++++++++++++++++
 bfd/config.bfd                              |  50 +++++++++
 bfd/config.in                               |   2 +
 bfd/configure                               |  24 +++++
 bfd/configure.ac                            |   6 ++
 bfd/configure.com                           |  12 ++-
 bfd/ecoff.c                                 |   9 ++
 bfd/elf-bfd.h                               |   3 +
 bfd/elf.c                                   |   3 +
 bfd/elflink.c                               |  23 +++++
 bfd/libbfd-in.h                             |   4 +
 bfd/libbfd.h                                |  28 +++++
 bfd/makefile.vms                            |   7 ++
 bfd/peicode.h                               |   4 +
 bfd/targets.c                               |  17 +++
 binutils/config.in                          |   2 +
 binutils/configure                          |   5 +
 binutils/configure.com                      |   1 +
 binutils/readelf.c                          | 103 ++++++++++++++++++
 binutils/testsuite/binutils-all/nm.exp      |  10 +-
 binutils/testsuite/binutils-all/objcopy.exp |   1 +
 binutils/testsuite/binutils-all/objdump.exp |   2 +-
 binutils/testsuite/lib/binutils-common.exp  |   2 +-
 config.guess                                |  41 ++++++++
 config.sub                                  |   1 +
 config/elf.m4                               |   2 +-
 config/intdiv0.m4                           |   2 +-
 config/picflag.m4                           |   3 +
 config/tcl.m4                               |   6 ++
 configure                                   |  39 ++++++-
 configure.ac                                |  37 ++++++-
 elfcpp/elfcpp.h                             |   2 +
 gas/Makefile.am                             |   2 +
 gas/Makefile.in                             |   5 +
 gas/as.c                                    |  13 ++-
 gas/as.h                                    |   6 ++
 gas/config.in                               |   9 ++
 gas/config/obj-ecoff.c                      |  10 ++
 gas/config/obj-elf.c                        |   6 ++
 gas/config/obj-elf.h                        |   5 +
 gas/configure                               |  19 ++++
 gas/configure.tgt                           |  10 +-
 gas/read.c                                  |   2 +-
 gas/testsuite/gas/all/gas.exp               |   7 ++
 gas/testsuite/gas/all/weakref1.d            |   3 +-
 gas/testsuite/gas/all/weakref1g.d           |   2 +-
 gas/testsuite/gas/all/weakref1l.d           |   2 +-
 gas/testsuite/gas/all/weakref1u.d           |   2 +-
 gas/testsuite/gas/all/weakref1w.d           |   2 +-
 gas/testsuite/gas/elf/common5a.d            |   2 +
 gas/testsuite/gas/elf/common5b.d            |   2 +
 gas/testsuite/gas/elf/common5c.d            |   2 +
 gas/testsuite/gas/elf/common5d.d            |   2 +
 gas/testsuite/gas/elf/elf.exp               |  14 ++-
 gas/testsuite/gas/elf/ifunc-1.d             |   1 +
 gas/testsuite/gas/elf/symtab.d              |   1 +
 gas/write.c                                 |  58 ++++++++++-
 gold/Makefile.am                            |   4 +-
 gold/Makefile.in                            |   5 +-
 gold/configure                              |  14 +++
 gold/configure.ac                           |   1 +
 gold/configure.tgt                          |   6 ++
 gold/reloc.h                                |   1 +
 gold/target-reloc.h                         |   4 +-
 include/coff/ecoff.h                        |  14 +++
 include/coff/pe.h                           |   4 +
 include/elf/common.h                        |   5 +
 include/longlong.h                          |  55 ++++++++++
 ld/Makefile.am                              |  10 ++
 ld/Makefile.in                              |  17 +++
 ld/config.in                                |   2 +
 ld/configure                                |   7 ++
 ld/configure.tgt                            |  16 +++
 ld/testsuite/config/default.exp             |  20 ++++
 ld/testsuite/ld-elf/binutils.exp            |   1 +
 ld/testsuite/ld-elf/compress1a.d            |   2 +-
 ld/testsuite/ld-elf/compressed1a.d          |   2 +-
 ld/testsuite/ld-elf/eh5.d                   |   2 +-
 ld/testsuite/ld-elf/elf.exp                 |   2 +-
 ld/testsuite/ld-elf/pr17550a.d              |   2 +-
 ld/testsuite/ld-elf/pr17550b.d              |   2 +-
 ld/testsuite/ld-elf/pr17550c.d              |   3 +
 ld/testsuite/ld-elf/pr17550d.d              |   3 +
 ld/testsuite/ld-elf/pr18720b.c              |   2 +
 ld/testsuite/ld-elf/shared.exp              |  13 ++-
 ld/testsuite/ld-elf/stab.d                  |   2 +-
 ld/testsuite/ld-elfvers/vers.exp            |   1 +
 ld/testsuite/ld-elfvsb/elfvsb.exp           |   4 +
 ld/testsuite/ld-elfweak/elfweak.exp         |   1 +
 ld/testsuite/ld-ifunc/ifunc-26.d            |   2 +-
 ld/testsuite/ld-ifunc/ifunc.exp             |   1 +
 ld/testsuite/ld-misc/just-symbols.exp       |   3 +-
 ld/testsuite/ld-plugin/plugin-14.d          |   1 +
 ld/testsuite/ld-plugin/plugin-15.d          |   1 +
 ld/testsuite/ld-plugin/plugin-16.d          |   1 +
 ld/testsuite/ld-plugin/plugin-20.d          |   1 +
 ld/testsuite/ld-plugin/plugin-21.d          |   1 +
 ld/testsuite/ld-plugin/plugin-22.d          |   1 +
 ld/testsuite/ld-plugin/plugin-23.d          |   1 +
 ld/testsuite/ld-plugin/plugin-6.d           |   1 +
 ld/testsuite/ld-plugin/plugin-7.d           |   1 +
 ld/testsuite/ld-plugin/plugin-8.d           |   1 +
 ld/testsuite/ld-scripts/fill.d              |   3 +-
 ld/testsuite/ld-scripts/fill16.d            |   3 +-
 ld/testsuite/ld-scripts/pr27100.d           |   2 +-
 ld/testsuite/ld-shared/shared.exp           |   4 +
 ld/testsuite/ld-srec/srec.exp               |   6 ++
 makefile.vms                                |   8 ++
 opcodes/Makefile.am                         |   2 +
 opcodes/Makefile.in                         |   4 +
 opcodes/config.in                           |   2 +
 opcodes/configure                           |   7 ++
 opcodes/configure.ac                        |   1 +
 opcodes/configure.com                       |   8 ++
 opcodes/disassemble.c                       |  10 ++
 opcodes/disassemble.h                       |   3 +
 121 files changed, 1041 insertions(+), 54 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 9b3a5d75..67156011 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -619,6 +619,7 @@ all:
 #### host and target specific makefile fragments come in here.
 @target_makefile_frag@
 @alphaieee_frag@
+@sw_64ieee_frag@
 @ospace_frag@
 @host_makefile_frag@
 ###
diff --git a/Makefile.tpl b/Makefile.tpl
index 84fee3dd..dda97b5d 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -572,6 +572,7 @@ all:
 #### host and target specific makefile fragments come in here.
 @target_makefile_frag@
 @alphaieee_frag@
+@sw_64ieee_frag@
 @ospace_frag@
 @host_makefile_frag@
 ###
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 7c859428..3aec8a2b 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -92,6 +92,7 @@ BFD64_LIBS_CFILES = archive64.c
 ALL_MACHINES = \
 	cpu-aarch64.lo \
 	cpu-alpha.lo \
+	cpu-sw_64.lo \
 	cpu-arc.lo \
 	cpu-arm.lo \
 	cpu-avr.lo \
@@ -176,6 +177,7 @@ ALL_MACHINES = \
 ALL_MACHINES_CFILES = \
 	cpu-aarch64.c \
 	cpu-alpha.c \
+	cpu-sw_64.c \
 	cpu-arc.c \
 	cpu-arm.c \
 	cpu-avr.c \
@@ -536,6 +538,7 @@ BFD64_BACKENDS = \
 	aix5ppc-core.lo \
 	aout64.lo \
 	coff-alpha.lo \
+	coff-sw_64.lo \
 	coff-x86_64.lo \
 	coff64-rs6000.lo \
 	elf32-ia64.lo \
@@ -543,6 +546,7 @@ BFD64_BACKENDS = \
 	elf32-score.lo \
 	elf32-score7.lo \
 	elf64-alpha.lo \
+	elf64-sw_64.lo \
 	elf64-gen.lo \
 	elf64-hppa.lo \
 	elf64-ia64.lo \
@@ -574,18 +578,21 @@ BFD64_BACKENDS = \
 	pei-x86_64.lo \
 	pepigen.lo \
 	pex64igen.lo \
-	vms-alpha.lo
+	vms-alpha.lo \
+	vms-sw_64.lo
 
 BFD64_BACKENDS_CFILES = \
 	aix5ppc-core.c \
 	aout64.c \
 	coff-alpha.c \
+	coff-sw_64.c \
 	coff-x86_64.c \
 	coff64-rs6000.c \
 	elf32-mips.c \
 	elf32-score.c \
 	elf32-score7.c \
 	elf64-alpha.c \
+	elf64-sw_64.c \
 	elf64-gen.c \
 	elf64-hppa.c \
 	elf64-ia64-vms.c \
@@ -612,7 +619,8 @@ BFD64_BACKENDS_CFILES = \
 	pei-aarch64.c \
 	pei-ia64.c \
 	pei-x86_64.c \
-	vms-alpha.c
+	vms-alpha.c \
+	vms-sw_64.c
 
 OPTIONAL_BACKENDS = \
 	aix386-core.lo \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 66fa92c1..32c1df38 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -517,6 +517,7 @@ BFD64_LIBS_CFILES = archive64.c
 ALL_MACHINES = \
 	cpu-aarch64.lo \
 	cpu-alpha.lo \
+	cpu-sw_64.lo \
 	cpu-arc.lo \
 	cpu-arm.lo \
 	cpu-avr.lo \
@@ -601,6 +602,7 @@ ALL_MACHINES = \
 ALL_MACHINES_CFILES = \
 	cpu-aarch64.c \
 	cpu-alpha.c \
+	cpu-sw_64.c \
 	cpu-arc.c \
 	cpu-arm.c \
 	cpu-avr.c \
@@ -963,6 +965,7 @@ BFD64_BACKENDS = \
 	aix5ppc-core.lo \
 	aout64.lo \
 	coff-alpha.lo \
+	coff-sw_64.lo \
 	coff-x86_64.lo \
 	coff64-rs6000.lo \
 	elf32-ia64.lo \
@@ -970,6 +973,7 @@ BFD64_BACKENDS = \
 	elf32-score.lo \
 	elf32-score7.lo \
 	elf64-alpha.lo \
+	elf64-sw_64.lo \
 	elf64-gen.lo \
 	elf64-hppa.lo \
 	elf64-ia64.lo \
@@ -1001,18 +1005,21 @@ BFD64_BACKENDS = \
 	pei-x86_64.lo \
 	pepigen.lo \
 	pex64igen.lo \
-	vms-alpha.lo
+	vms-alpha.lo \
+	vms-sw_64.lo
 
 BFD64_BACKENDS_CFILES = \
 	aix5ppc-core.c \
 	aout64.c \
 	coff-alpha.c \
+	coff-sw_64.c \
 	coff-x86_64.c \
 	coff64-rs6000.c \
 	elf32-mips.c \
 	elf32-score.c \
 	elf32-score7.c \
 	elf64-alpha.c \
+	elf64-sw_64.c \
 	elf64-gen.c \
 	elf64-hppa.c \
 	elf64-ia64-vms.c \
@@ -1039,7 +1046,8 @@ BFD64_BACKENDS_CFILES = \
 	pei-aarch64.c \
 	pei-ia64.c \
 	pei-x86_64.c \
-	vms-alpha.c
+	vms-alpha.c \
+	vms-sw_64.c
 
 OPTIONAL_BACKENDS = \
 	aix386-core.lo \
@@ -1306,6 +1314,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cf-i386lynx.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cisco-core.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-alpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-sw_64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-bfd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-go32.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-i386.Plo@am__quote@
@@ -1326,6 +1335,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corefile.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-aarch64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-alpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-sw_64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-arc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-arm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-avr.Plo@am__quote@
@@ -1490,6 +1500,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-aarch64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-alpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-sw_64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-bpf.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-gen.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-hppa.Plo@am__quote@
@@ -1579,6 +1590,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vaxnetbsd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verilog.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-alpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-sw_64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-lib.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-misc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wasm-module.Plo@am__quote@
diff --git a/bfd/archures.c b/bfd/archures.c
index 390691bf..c5b07827 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -24,6 +24,9 @@
 #include "libbfd.h"
 #include "safe-ctype.h"
 
+/* add sw_64 target
+ * add cpu sw6a-1621, sw6b-3231.  */
+
 /*
 
 SECTION
@@ -308,6 +311,11 @@ DESCRIPTION
 .#define bfd_mach_alpha_ev4	0x10
 .#define bfd_mach_alpha_ev5	0x20
 .#define bfd_mach_alpha_ev6	0x30
+.#ifdef TARGET_SW_64
+.  bfd_arch_sw_64,     {* Sw_64 *}
+.#define bfd_mach_sw_64_sw6a  4
+.#define bfd_mach_sw_64_sw6b  8
+.#endif
 .  bfd_arch_arm,       {* Advanced Risc Machines ARM.  *}
 .#define bfd_mach_arm_unknown	0
 .#define bfd_mach_arm_2		1
@@ -610,6 +618,7 @@ DESCRIPTION
 
 extern const bfd_arch_info_type bfd_aarch64_arch;
 extern const bfd_arch_info_type bfd_alpha_arch;
+extern const bfd_arch_info_type bfd_sw_64_arch;
 extern const bfd_arch_info_type bfd_arc_arch;
 extern const bfd_arch_info_type bfd_arm_arch;
 extern const bfd_arch_info_type bfd_avr_arch;
@@ -699,6 +708,9 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
 #else
     &bfd_aarch64_arch,
     &bfd_alpha_arch,
+#ifdef TARGET_SW_64
+    &bfd_sw_64_arch,
+#endif
     &bfd_arc_arch,
     &bfd_arm_arch,
     &bfd_avr_arch,
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 5abde5fe..fc2f9b56 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1680,6 +1680,11 @@ enum bfd_architecture
 #define bfd_mach_alpha_ev4     0x10
 #define bfd_mach_alpha_ev5     0x20
 #define bfd_mach_alpha_ev6     0x30
+#ifdef TARGET_SW_64
+  bfd_arch_sw_64,     /* Sw_64 */
+#define bfd_mach_sw_64_sw6a  4
+#define bfd_mach_sw_64_sw6b  8
+#endif
   bfd_arch_arm,       /* Advanced Risc Machines ARM.  */
 #define bfd_mach_arm_unknown   0
 #define bfd_mach_arm_2         1
@@ -2518,6 +2523,110 @@ between two procedure entry points is < 2^21, or else a hint.  */
   BFD_RELOC_ALPHA_TPREL_LO16,
   BFD_RELOC_ALPHA_TPREL16,
 
+#ifdef TARGET_SW_64
+/* Sw_64 ECOFF and ELF relocations.  Some of these treat the symbol or
+"addend" in some special way.
+For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
+writing; when reading, it will be the absolute section symbol.  The
+addend is the displacement in bytes of the "lda" instruction from
+the "ldah" instruction (which is at the address of this reloc).  */
+  BFD_RELOC_SW_64_GPDISP_HI16,  
+
+/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
+with GPDISP_HI16 relocs.  The addend is ignored when writing the
+relocations out, and is filled in with the file's GP value on
+reading, for convenience.  */
+  BFD_RELOC_SW_64_GPDISP_LO16,
+
+/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
+relocation except that there is no accompanying GPDISP_LO16
+relocation.  */
+  BFD_RELOC_SW_64_GPDISP,
+
+/* The Sw_64 LITERAL/LITUSE relocs are produced by a symbol reference;
+the assembler turns it into a LDQ instruction to load the address of
+the symbol, and then fills in a register in the real instruction.
+
+The LITERAL reloc, at the LDQ instruction, refers to the .lita
+section symbol.  The addend is ignored when writing, but is filled
+in with the file's GP value on reading, for convenience, as with the
+GPDISP_LO16 reloc.
+
+The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
+It should refer to the symbol to be referenced, as with 16_GOTOFF,
+but it generates output not based on the position within the .got
+section, but relative to the GP value chosen for the file during the
+final link stage.
+
+The LITUSE reloc, on the instruction using the loaded address, gives
+information to the linker that it might be able to use to optimize
+away some literal section references.  The symbol is ignored (read
+as the absolute section symbol), and the "addend" indicates the type
+of instruction using the register:
+1 - "memory" fmt insn
+2 - byte-manipulation (byte offset reg)
+3 - jsr (target of branch)  */
+  BFD_RELOC_SW_64_LITERAL,
+  BFD_RELOC_SW_64_ELF_LITERAL,
+  BFD_RELOC_SW_64_ELF_LITERAL_GOT,
+  BFD_RELOC_SW_64_LITUSE,
+
+/* The HINT relocation indicates a value that should be filled into the
+"hint" field of a jmp/jsr/ret instruction, for possible branch-
+prediction logic which may be provided on some processors.  */
+  BFD_RELOC_SW_64_HINT,
+
+/* The LINKAGE relocation outputs a linkage pair in the object file,
+which is filled by the linker.  */
+  BFD_RELOC_SW_64_LINKAGE,
+
+/* The CODEADDR relocation outputs a STO_CA in the object file,
+which is filled by the linker.  */
+  BFD_RELOC_SW_64_CODEADDR,
+
+/* The GPREL_HI/LO relocations together form a 32-bit offset from the
+GP register.  */
+  BFD_RELOC_SW_64_GPREL_HI16,
+  BFD_RELOC_SW_64_GPREL_LO16,
+
+/* Like BFD_RELOC_23_PCREL_S2, except that the source and target must
+share a common GP, and the target address is adjusted for
+STO_SW_64_STD_GPLOAD.  */
+  BFD_RELOC_SW_64_BRSGP,
+
+/* The NOP relocation outputs a NOP if the longword displacement
+between two procedure entry points is < 2^21.  */
+  BFD_RELOC_SW_64_NOP,
+
+/* The BSR relocation outputs a BSR if the longword displacement
+between two procedure entry points is < 2^21.  */
+  BFD_RELOC_SW_64_BSR,
+      
+/* The LDA relocation outputs a LDA if the longword displacement
+between two procedure entry points is < 2^16.  */
+  BFD_RELOC_SW_64_LDA,
+
+/* The BOH relocation outputs a BSR if the longword displacement
+between two procedure entry points is < 2^21, or else a hint.  */
+  BFD_RELOC_SW_64_BOH,
+
+/* Sw_64 thread-local storage relocations.  */
+  BFD_RELOC_SW_64_TLSGD,
+  BFD_RELOC_SW_64_TLSLDM,
+  BFD_RELOC_SW_64_DTPMOD64,
+  BFD_RELOC_SW_64_GOTDTPREL16,
+  BFD_RELOC_SW_64_DTPREL64,
+  BFD_RELOC_SW_64_DTPREL_HI16,
+  BFD_RELOC_SW_64_DTPREL_LO16,
+  BFD_RELOC_SW_64_DTPREL16,
+  BFD_RELOC_SW_64_GOTTPREL16,
+  BFD_RELOC_SW_64_TPREL64,
+  BFD_RELOC_SW_64_TPREL_HI16,
+  BFD_RELOC_SW_64_TPREL_LO16,
+  BFD_RELOC_SW_64_TPREL16,
+  BFD_RELOC_SW_64_BR26,
+#endif
+
 /* The MIPS jump instruction.  */
   BFD_RELOC_MIPS_JMP,
   BFD_RELOC_MICROMIPS_JMP,
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 81f4943e..9cbf7016 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -165,6 +165,7 @@ targ_cpu=`echo $targ | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 case "${targ_cpu}" in
 aarch64*)	 targ_archs="bfd_aarch64_arch bfd_arm_arch";;
 alpha*)		 targ_archs=bfd_alpha_arch ;;
+sw_64*)          targ_archs=bfd_sw_64_arch ;;
 am33_2.0*)	 targ_archs=bfd_mn10300_arch ;;
 arc*)		 targ_archs=bfd_arc_arch ;;
 arm*)		 targ_archs=bfd_arm_arch ;;
@@ -299,6 +300,55 @@ case "${targ}" in
     targ_defvec=alpha_ecoff_le_vec
     want64=true
     ;;
+  sw_64*-*-freebsd* | sw_64*-*-kfreebsd*-gnu)
+    targ_defvec=sw_64_elf64_fbsd_vec
+    targ_selvecs="sw_64_elf64_vec sw_64_ecoff_le_vec"
+    want64=true
+    # FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling.
+    case "${targ}" in
+      sw_64*-*-freebsd3* | sw_64*-*-freebsd4 | sw_64*-*-freebsd4.0*)
+        targ_cflags=-DOLD_FREEBSD_ABI_LABEL ;;
+    esac
+    ;;
+  sw_64*-*-netbsd* | sw_64*-*-openbsd*)
+    targ_defvec=sw_64_elf64_vec
+    targ_selvecs=sw_64_ecoff_le_vec
+    want64=true
+    ;;
+  sw_64*-*-netware*)
+    targ_defvec=sw_64_ecoff_le_vec
+    targ_selvecs=sw_64_nlm32_vec
+    want64=true
+    ;;
+  sw_64*-*-linux*ecoff*)
+    targ_defvec=sw_64_ecoff_le_vec
+    targ_selvecs=sw_64_elf64_vec
+    want64=true
+    ;;
+  sw_64-*-linux-* | sw_64-*-elf*)
+    targ_defvec=sw_64_elf64_vec
+    targ_selvecs=sw_64_ecoff_le_vec
+    want64=true
+    ;;
+  sw_64sw6a-*-linux-* | sw_64sw6a-*-elf*)
+    targ_defvec=sw_64_elf64_vec
+    targ_selvecs=sw_64_ecoff_le_vec
+    want64=true
+    ;;
+  sw_64sw6b-*-linux-* | sw_64sw6b-*-elf*)
+    targ_defvec=sw_64_elf64_vec
+    targ_selvecs=sw_64_ecoff_le_vec
+    want64=true
+    ;;
+  sw_64*-*-*vms*)
+    targ_defvec=sw_64_vms_vec
+    targ_selvecs=sw_64_vms_lib_txt_vec
+    want64=true
+    ;;
+  sw_64*-*-*)
+    targ_defvec=sw_64_ecoff_le_vec
+    want64=true
+    ;;
   ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
     targ_defvec=ia64_elf64_le_vec
     targ_selvecs="ia64_elf64_be_vec ia64_pei_vec"
diff --git a/bfd/config.in b/bfd/config.in
index f54a3cac..03d878d1 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -341,3 +341,5 @@
 
 /* Use structured /proc on Solaris. */
 #undef _STRUCTURED_PROC
+
+#undef TARGET_SW_64
diff --git a/bfd/configure b/bfd/configure
index fe8658e3..55e14c64 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -11907,6 +11907,11 @@ i[34567]86-*-linux-* | x86_64-*-linux-*)
     ac_default_ld_z_separate_code=1
   fi
   ;;
+sw_64-*-linux-*)
+cat >>confdefs.h <<_ACEOF
+#define TARGET_SW_64
+_ACEOF
+  ;;
 esac
 if test "${ac_default_ld_z_separate_code}" = unset; then
   ac_default_ld_z_separate_code=0
@@ -13287,6 +13292,12 @@ do
     alpha_elf64_fbsd_vec)	 tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
     alpha_vms_vec)		 tb="$tb vms-alpha.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
     alpha_vms_lib_txt_vec)	 tb="$tb vms-lib.lo vms-misc.lo" ;;
+    sw_64_ecoff_le_vec)          tb="$tb coff-sw_64.lo ecoff.lo $ecoff"; target_size=64 ;;
+    sw_64_elf64_vec)             tb="$tb elf64-sw_64.lo elf64.lo $elf"; target_size=64 ;;
+    sw_64_elf64_fbsd_vec)        tb="$tb elf64-sw_64.lo elf64.lo $elf"; target_size=64 ;;
+    sw_64_nlm32_vec)             tb="$tb nlm32-sw_64.lo nlm32.lo nlm.lo"; target_size=64 ;;
+    sw_64_vms_vec)               tb="$tb vms-sw_64.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
+    sw_64_vms_lib_txt_vec)       tb="$tb vms-lib.lo vms-misc.lo" ;;
     am33_elf32_linux_vec)	 tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
     aout0_be_vec)		 tb="$tb aout0.lo aout32.lo" ;;
     aout64_vec)			 tb="$tb demo64.lo aout64.lo"; target_size=64 ;;
@@ -13701,6 +13712,19 @@ if test "${target}" = "${host}"; then
   alpha*-*-*)
         COREFILE=osf-core.lo
 	;;
+  sw_64*-*-freebsd* | sw_64*-*-kfreebsd*-gnu | sw_64*-*-*vms*)
+	COREFILE=''
+	;;
+  sw_64*-*-linux-*)
+        COREFILE=trad-core.lo
+        TRAD_HEADER='"hosts/sw_64linux.h"'
+        ;;
+  sw_64*-*-netbsd* | sw_64*-*-openbsd*)
+        COREFILE=netbsd-core.lo
+        ;;
+  sw_64*-*-*)
+        COREFILE=osf-core.lo
+        ;;
   arm-*-freebsd* | arm-*-kfreebsd*-gnu)
 	COREFILE='' ;;
   arm*-*-netbsd* | arm-*-openbsd*)
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 577824b5..9493b900 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -443,6 +443,12 @@ do
     alpha_elf64_fbsd_vec)	 tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
     alpha_vms_vec)		 tb="$tb vms-alpha.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
     alpha_vms_lib_txt_vec)	 tb="$tb vms-lib.lo vms-misc.lo" ;;
+    sw_64_ecoff_le_vec)          tb="$tb coff-sw_64.lo ecoff.lo $ecoff"; target_size=64 ;;
+    sw_64_elf64_vec)             tb="$tb elf64-sw_64.lo elf64.lo $elf"; target_size=64 ;;
+    sw_64_elf64_fbsd_vec)        tb="$tb elf64-sw_64.lo elf64.lo $elf"; target_size=64 ;;
+    sw_64_nlm32_vec)             tb="$tb nlm32-sw_64.lo nlm32.lo nlm.lo"; target_size=64 ;;
+    sw_64_vms_vec)               tb="$tb vms-sw_64.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
+    sw_64_vms_lib_txt_vec)       tb="$tb vms-lib.lo vms-misc.lo" ;;
     am33_elf32_linux_vec)	 tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
     aout0_be_vec)		 tb="$tb aout0.lo aout32.lo" ;;
     aout64_vec)			 tb="$tb demo64.lo aout64.lo"; target_size=64 ;;
diff --git a/bfd/configure.com b/bfd/configure.com
index 0a663ca0..fa4be994 100644
--- a/bfd/configure.com
+++ b/bfd/configure.com
@@ -26,9 +26,10 @@ $!
 $ arch=F$GETSYI("ARCH_NAME")
 $ arch=F$EDIT(arch,"LOWERCASE")
 $if arch .eqs. "alpha" then target = "alpha"
+$if arch .eqs. "sw_64" then target = "sw_64"
 $if arch .eqs. "ia64" then target = "ia64"
 $!
-$if (arch .eqs. "alpha") .or. (arch .eqs. "ia64")
+$if (arch .eqs. "alpha") .or. (arch .eqs. "ia64") .or. (arch .eqs. "sw_64")
 $then
 $!
 $ write sys$output "Configuring BFD for ''target' target"
@@ -328,6 +329,15 @@ $ DEFS="""SELECT_VECS=&alpha_vms_vec"","+-
 $ FILES="cpu-alpha,vms,vms-hdr,vms-gsd,vms-tir,vms-misc,"
 $EOD
 $ endif
+$ if ARCH.eqs."sw_64"
+$ then
+$   create build.com
+$DECK
+$ DEFS="""SELECT_VECS=&sw_64_vms_vec"","+-
+  """SELECT_ARCHITECTURES=&bfd_sw_64_arch"""
+$ FILES="cpu-sw_64,vms,vms-hdr,vms-gsd,vms-tir,vms-misc,"
+$EOD
+$ endif
 $ if ARCH.eqs."ia64"
 $ then
 $   create build.com
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 7844a50b..f13ccb74 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -202,6 +202,12 @@ _bfd_ecoff_set_arch_mach_hook (bfd *abfd, void * filehdr)
       mach = 0;
       break;
 
+#ifdef TARGET_SW_64
+    case SW_64_MAGIC:
+      arch = bfd_arch_sw_64;
+      mach = 0;
+      break;
+#endif
     default:
       arch = bfd_arch_obscure;
       mach = 0;
@@ -255,6 +261,9 @@ ecoff_get_magic (bfd *abfd)
     case bfd_arch_alpha:
       return ALPHA_MAGIC;
 
+    case bfd_arch_sw_64:
+      return SW_64_MAGIC;
+
     default:
       abort ();
       return 0;
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 8f985ab8..f6499b34 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -496,6 +496,9 @@ enum elf_target_id
 {
   AARCH64_ELF_DATA = 1,
   ALPHA_ELF_DATA,
+#ifdef TARGET_SW_64
+  SW_64_ELF_DATA,
+#endif
   ARC_ELF_DATA,
   ARM_ELF_DATA,
   AVR_ELF_DATA,
diff --git a/bfd/elf.c b/bfd/elf.c
index 9c3f34c4..81a31ec0 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -11013,6 +11013,9 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
 
     case bfd_arch_aarch64:
     case bfd_arch_alpha:
+#ifdef TARGET_SW_64
+    case bfd_arch_sw_64:
+#endif
     case bfd_arch_sparc:
       switch (note->type)
 	{
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 9a052082..5589c4d9 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4106,6 +4106,16 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
     }
 
   ehdr = elf_elfheader (abfd);
+#ifdef TARGET_SW_64
+   if(ehdr->e_machine != 0x9916)
+   {
+       char obj_elf_path[4096]={0};
+       char obj_buff[4094];
+       readlink("/proc/sel/exe",obj_elf_path,4096);
+       sprintf(obj_buff,"fail to load_symbols %s,process_name %s\n",abfd->filename,obj_elf_path);
+       //syslog(LOG_ALERT,obj_buff,strlen(obj_buff));
+   }
+#endif
   if (info->warn_alternate_em
       && bed->elf_machine_code != ehdr->e_machine
       && ((bed->elf_machine_alt1 != 0
@@ -5922,6 +5932,19 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
 	  if (!bfd_link_add_symbols (element, info))
 	    goto error_return;
 
+#ifdef TARGET_SW_64
+          Elf_Internal_Ehdr *archive_ehdrp;   /* Elf file header, internal form.  */
+          archive_ehdrp = elf_elfheader (element);
+          if(archive_ehdrp->e_machine != 0x9916)
+          {
+              char archive_elf_path[4096]={0};
+              char archive_buff[4096];
+              readlink("/proc/sel/exe",archive_elf_path,4096);
+              sprintf(archive_buff,"fail to load_symbols %s,process_name %s\n",element->filename,archive_elf_path);
+              //syslog(LOG_ALERT,archive_buff,strlen(archive_buff));
+          }
+#endif
+
 	  /* If there are any new undefined symbols, we need to make
 	     another pass through the archive in order to see whether
 	     they can be defined.  FIXME: This isn't perfect, because
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 1f7e2218..21935c2f 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -424,8 +424,12 @@ extern bfd_cleanup _bfd_vms_lib_alpha_archive_p
   (bfd *) ATTRIBUTE_HIDDEN;
 extern bfd_cleanup _bfd_vms_lib_ia64_archive_p
   (bfd *) ATTRIBUTE_HIDDEN;
+extern const bfd_target *_bfd_vms_lib_sw_64_archive_p
+  (bfd *) ATTRIBUTE_HIDDEN;
 extern bool _bfd_vms_lib_alpha_mkarchive
   (bfd *) ATTRIBUTE_HIDDEN;
+extern bfd_boolean _bfd_vms_lib_sw_64_mkarchive
+  (bfd *) ATTRIBUTE_HIDDEN;
 extern bool _bfd_vms_lib_ia64_mkarchive
   (bfd *) ATTRIBUTE_HIDDEN;
 
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index c37ddc03..9ad9adf5 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1214,6 +1214,34 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_ALPHA_TPREL_HI16",
   "BFD_RELOC_ALPHA_TPREL_LO16",
   "BFD_RELOC_ALPHA_TPREL16",
+#ifdef TARGET_SW_64
+  "BFD_RELOC_SW_64_GPDISP_HI16",
+  "BFD_RELOC_SW_64_GPDISP_LO16",
+  "BFD_RELOC_SW_64_GPDISP",
+  "BFD_RELOC_SW_64_LITERAL",
+  "BFD_RELOC_SW_64_ELF_LITERAL",
+  "BFD_RELOC_SW_64_LITUSE",
+  "BFD_RELOC_SW_64_HINT",
+  "BFD_RELOC_SW_64_LINKAGE",
+  "BFD_RELOC_SW_64_CODEADDR",
+  "BFD_RELOC_SW_64_GPREL_HI16",
+  "BFD_RELOC_SW_64_GPREL_LO16",
+  "BFD_RELOC_SW_64_BRSGP"
+  "BFD_RELOC_SW_64_NOP",
+  "BFD_RELOC_SW_64_BSR",
+  "BFD_RELOC_SW_64_LDA",
+  "BFD_RELOC_SW_64_BOH",
+  "BFD_RELOC_SW_64_TLSGD",
+  "BFD_RELOC_SW_64_TLSLDM",
+  "BFD_RELOC_SW_64_DTPMOD64",
+  "BFD_RELOC_SW_64_GOTDTPREL16",
+  "BFD_RELOC_SW_64_DTPREL64",
+  "BFD_RELOC_SW_64_DTPREL_HI16",
+  "BFD_RELOC_SW_64_DTPREL_LO16",
+  "BFD_RELOC_SW_64_DTPREL16",
+  "BFD_RELOC_SW_64_GOTTPREL16",
+  "BFD_RELOC_SW_64_TPREL64",
+#endif
   "BFD_RELOC_MIPS_JMP",
   "BFD_RELOC_MICROMIPS_JMP",
   "BFD_RELOC_MIPS16_JMP",
diff --git a/bfd/makefile.vms b/bfd/makefile.vms
index 4efe1581..21b9f16e 100644
--- a/bfd/makefile.vms
+++ b/bfd/makefile.vms
@@ -36,6 +36,13 @@ OBJS:=vms-alpha.obj,vms-lib.obj,vms-misc.obj,cpu-alpha.obj
 DEFS=SELECT_VECS="&alpha_vms_vec",SELECT_ARCHITECTURES="&bfd_alpha_arch"
 endif
 
+ifeq ($(ARCH),SW_64)
+HOSTFILE=sw_64vms.h
+OBJS:=vms-sw_64.obj,vms-lib.obj,vms-misc.obj,cpu-sw_64.obj
+DEFS=SELECT_VECS="&sw_64_vms_vec",SELECT_ARCHITECTURES="&bfd_sw_64_arch"
+endif
+
+
 OBJS:=$(OBJS),archive.obj,archive64.obj,archures.obj,bfd.obj,bfdio.obj,\
   binary.obj,cache.obj,coffgen.obj,compress.obj,corefile.obj,dwarf2.obj,\
   elf.obj,format.obj,hash.obj,ihex.obj,init.obj,libbfd.obj,linker.obj,\
diff --git a/bfd/peicode.h b/bfd/peicode.h
index 9374e232..4e7a7486 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -1176,6 +1176,10 @@ pe_ILF_object_p (bfd * abfd)
     case IMAGE_FILE_MACHINE_UNKNOWN:
     case IMAGE_FILE_MACHINE_ALPHA:
     case IMAGE_FILE_MACHINE_ALPHA64:
+#ifdef TARGET_SW_64
+    case IMAGE_FILE_MACHINE_SW_64:
+    case IMAGE_FILE_MACHINE_SW_6464:
+#endif
     case IMAGE_FILE_MACHINE_IA64:
       break;
 
diff --git a/bfd/targets.c b/bfd/targets.c
index ae6075b3..362a0dc9 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -685,6 +685,14 @@ extern const bfd_target alpha_elf64_vec;
 extern const bfd_target alpha_elf64_fbsd_vec;
 extern const bfd_target alpha_vms_vec;
 extern const bfd_target alpha_vms_lib_txt_vec;
+#ifdef TARGET_SW_64
+extern const bfd_target sw_64_ecoff_le_vec;
+extern const bfd_target sw_64_elf64_vec;
+extern const bfd_target sw_64_elf64_fbsd_vec;
+extern const bfd_target sw_64_nlm32_vec;
+extern const bfd_target sw_64_vms_vec;
+extern const bfd_target sw_64_vms_lib_txt_vec;
+#endif
 extern const bfd_target am33_elf32_linux_vec;
 extern const bfd_target aout_vec;
 extern const bfd_target arc_elf32_be_vec;
@@ -1003,6 +1011,15 @@ static const bfd_target * const _bfd_target_vector[] =
 #endif
 	&alpha_vms_lib_txt_vec,
 
+#ifdef BFD64
+        &sw_64_ecoff_le_vec,
+        &sw_64_elf64_vec,
+        &sw_64_elf64_fbsd_vec,
+        &sw_64_nlm32_vec,
+        &sw_64_vms_vec,
+#endif
+        &sw_64_vms_lib_txt_vec,
+
 	&am33_elf32_linux_vec,
 
 #if 0
diff --git a/binutils/config.in b/binutils/config.in
index e6fa66fc..44c1d17a 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -260,3 +260,5 @@
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+#undef TARGET_SW_64
diff --git a/binutils/configure b/binutils/configure
index 186ed103..e2f04ca1 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -14614,6 +14614,11 @@ do
   	mep-*)
 	  OBJDUMP_DEFS="-DSKIP_ZEROES=256 -DSKIP_ZEROES_AT_END=0"
 	  ;;
+  	sw_64-*-*)
+cat >>confdefs.h <<_ACEOF
+#define TARGET_SW_64
+_ACEOF
+    ;;
 	esac
 
 	# Add objdump private vectors.
diff --git a/binutils/configure.com b/binutils/configure.com
index 7b4a0b8d..85eddd39 100644
--- a/binutils/configure.com
+++ b/binutils/configure.com
@@ -84,6 +84,7 @@ $! Add TARGET.
 $!
 $ if arch .eqs. "ia64" then target = "elf64-ia64-vms"
 $ if arch .eqs. "alpha" then target = "vms-alpha"
+$ if arch .eqs. "sw_64" then target = "vms-sw_64"
 $ if arch .eqs. "vax" then target = "vms-vax"
 $!
 $ open/append tfile config.h
diff --git a/binutils/readelf.c b/binutils/readelf.c
index cc9023aa..06dba4cf 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -91,6 +91,9 @@
 
 #include "elf/aarch64.h"
 #include "elf/alpha.h"
+#ifdef TARGET_SW_64
+#include "elf/sw_64.h"
+#endif
 #include "elf/arc.h"
 #include "elf/arm.h"
 #include "elf/avr.h"
@@ -1021,6 +1024,9 @@ guess_is_rela (unsigned int e_machine)
     case EM_AARCH64:
     case EM_ADAPTEVA_EPIPHANY:
     case EM_ALPHA:
+#ifdef TARGET_SW_64
+    case EM_SW_64:
+#endif
     case EM_ALTERA_NIOS2:
     case EM_ARC:
     case EM_ARC_COMPACT:
@@ -1617,6 +1623,12 @@ dump_relocations (Filedata *          filedata,
 	  rtype = elf_alpha_reloc_type (type);
 	  break;
 
+#ifdef TARGET_SW_64
+        case EM_SW_64:
+          rtype = elf_sw_64_reloc_type (type);
+          break;
+#endif
+
 	case EM_ARM:
 	  rtype = elf_arm_reloc_type (type);
 	  break;
@@ -1833,6 +1845,35 @@ dump_relocations (Filedata *          filedata,
 	      res = false;
 	    }
 	}
+#ifdef TARGET_SW_64
+      else if (filedata->file_header.e_machine ==  EM_SW_64
+	  && rtype != NULL
+	  && streq (rtype, "R_SW_64_LITUSE")
+	  )
+	  //&& is_rela)
+	{
+	  switch (rels[i].r_addend)
+	    {
+            case LITUSE_SW_64_ADDR:   rtype = "ADDR";   break;
+            case LITUSE_SW_64_BASE:   rtype = "BASE";   break;
+            case LITUSE_SW_64_BYTOFF: rtype = "BYTOFF"; break;
+            case LITUSE_SW_64_JSR:    rtype = "JSR";    break;
+            case LITUSE_SW_64_TLSGD:  rtype = "TLSGD";  break;
+            case LITUSE_SW_64_TLSLDM: rtype = "TLSLDM"; break;
+            case LITUSE_SW_64_JSRDIRECT: rtype = "JSRDIRECT"; break;				
+	    default: rtype = NULL;
+	    }
+	  if (rtype)
+	    printf (" (%s)", rtype);
+	  else
+	    {
+	      putchar (' ');
+	      printf (_("<unknown addend: %lx>"),
+		      (unsigned long) rels[i].r_addend);
+	      res = false;
+	    }
+	}
+#endif
       else if (symtab_index)
 	{
 	  if (symtab == NULL || symtab_index >= nsyms)
@@ -2238,6 +2279,18 @@ get_alpha_dynamic_type (unsigned long type)
     }
 }
 
+#ifdef TARGET_SW_64
+static const char *
+get_sw_64_dynamic_type (unsigned long type)
+{
+  switch (type)
+    {
+    case DT_SW_64_PLTRO: return "SW_64_PLTRO";
+    default: return NULL;
+    }
+}
+#endif
+
 static const char *
 get_score_dynamic_type (unsigned long type)
 {
@@ -2428,6 +2481,11 @@ get_dynamic_type (Filedata * filedata, unsigned long type)
 	    case EM_ALPHA:
 	      result = get_alpha_dynamic_type (type);
 	      break;
+#ifdef TARGET_SW_64
+            case EM_SW_64:
+              result = get_sw_64_dynamic_type (type);
+              break;
+#endif	    
 	    case EM_SCORE:
 	      result = get_score_dynamic_type (type);
 	      break;
@@ -2845,6 +2903,9 @@ get_machine_name (unsigned e_machine)
       /* Large numbers...  */
     case EM_MT:                 return "Morpho Techologies MT processor";
     case EM_ALPHA:		return "Alpha";
+#ifdef TARGET_SW_64
+    case EM_SW_64:              return "Sw_64";
+#endif
     case EM_WEBASSEMBLY:	return "Web Assembly";
     case EM_DLX:		return "OpenDLX";
     case EM_XSTORMY16:		return "Sanyo XStormy16 CPU core";
@@ -12355,6 +12416,21 @@ get_alpha_symbol_other (unsigned int other)
     }
 }
 
+#ifdef TARGET_SW_64
+static const char *
+get_sw_64_symbol_other (unsigned int other)
+{
+  switch (other)
+    {
+    case STO_SW_64_NOPV:       return "NOPV";
+    case STO_SW_64_STD_GPLOAD: return "STD GPLOAD";
+    default:
+      error (_("Unrecognized sw_64 specific other value: %u"), other);
+      return _("<unknown>");
+    }
+}
+#endif
+
 static const char *
 get_solaris_symbol_visibility (unsigned int visibility)
 {
@@ -12497,6 +12573,11 @@ get_symbol_other (Filedata * filedata, unsigned int other)
     case EM_ALPHA:
       result = get_alpha_symbol_other (other);
       break;
+#ifdef TARGET_SW_64
+    case EM_SW_64:
+      result = get_sw_64_symbol_other (other);
+      break;
+#endif
     case EM_AARCH64:
       result = get_aarch64_symbol_other (other);
       break;
@@ -13790,6 +13871,10 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 3;
     case EM_ALPHA:
       return reloc_type == 1; /* R_ALPHA_REFLONG.  */
+#ifdef TARGET_SW_64
+    case EM_SW_64:  
+      return reloc_type == 1; /* R_SW_64_REFLONG.  */
+#endif
     case EM_ARC:
       return reloc_type == 1; /* R_ARC_32.  */
     case EM_ARC_COMPACT:
@@ -13987,6 +14072,10 @@ is_32bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 6;
     case EM_ALPHA:
       return reloc_type == 10; /* R_ALPHA_SREL32.  */
+#ifdef TARGET_SW_64
+    case EM_SW_64:
+      return reloc_type == 10; /* R_SW_64_SREL32.  */
+#endif
     case EM_ARC_COMPACT:
     case EM_ARC_COMPACT2:
       return reloc_type == 49; /* R_ARC_32_PCREL.  */
@@ -14055,6 +14144,10 @@ is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 257;	/* R_AARCH64_ABS64.  */
     case EM_ALPHA:
       return reloc_type == 2; /* R_ALPHA_REFQUAD.  */
+#ifdef TARGET_SW_64
+    case EM_SW_64:
+      return reloc_type == 2; /* R_SW_64_REFQUAD.  */
+#endif
     case EM_IA_64:
       return (reloc_type == 0x26    /* R_IA64_DIR64MSB.  */
 	      || reloc_type == 0x27 /* R_IA64_DIR64LSB.  */);
@@ -14097,6 +14190,10 @@ is_64bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 260;	/* R_AARCH64_PREL64.  */
     case EM_ALPHA:
       return reloc_type == 11; /* R_ALPHA_SREL64.  */
+#ifdef TARGET_SW_64
+    case EM_SW_64:
+      return reloc_type == 11; /* R_SW_64_SREL64.  */
+#endif
     case EM_IA_64:
       return (reloc_type == 0x4e    /* R_IA64_PCREL64MSB.  */
 	      || reloc_type == 0x4f /* R_IA64_PCREL64LSB.  */);
@@ -14402,6 +14499,9 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_68K:     /* R_68K_NONE.  */
     case EM_ADAPTEVA_EPIPHANY:
     case EM_ALPHA:   /* R_ALPHA_NONE.  */
+#ifdef TARGET_SW_64
+    case EM_SW_64:   /* R_SW_64_NONE.  */
+#endif
     case EM_ALTERA_NIOS2: /* R_NIOS2_NONE.  */
     case EM_ARC:     /* R_ARC_NONE.  */
     case EM_ARC_COMPACT2: /* R_ARC_NONE.  */
@@ -20039,6 +20139,9 @@ get_netbsd_elfcore_note_type (Filedata * filedata, unsigned e_type)
 
     case EM_OLD_ALPHA:
     case EM_ALPHA:
+#ifdef TARGET_SW_64
+    case EM_SW_64:
+#endif
     case EM_SPARC:
     case EM_SPARC32PLUS:
     case EM_SPARCV9:
diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp
index 93753199..5a352dd2 100644
--- a/binutils/testsuite/binutils-all/nm.exp
+++ b/binutils/testsuite/binutils-all/nm.exp
@@ -44,7 +44,7 @@ if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
 
     # This test does not work correctly on ECOFF targets, because ECOFF
     # stores most symbols twice, which messes up the nm output.
-    setup_xfail "alpha*-*-osf*"
+    setup_xfail "alpha*-*-osf*" "sw_64*-*-ecoff*"
     setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
     setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
 
@@ -104,7 +104,7 @@ if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
 
     # This test does not work correctly on ECOFF targets, because ECOFF
     # stores most symbols twice, which messes up the nm output.
-    setup_xfail "alpha*-*-osf*"
+    setup_xfail "alpha*-*-osf*" "sw_64*-*-ecoff*"
     setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
     setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
 
@@ -183,7 +183,7 @@ if {![binutils_assemble $srcdir/$subdir/$nm_1_src tmpdir/nm-1.o]} then {
 
     # This test does not work correctly on ECOFF targets, because ECOFF
     # stores most symbols twice, which messes up the nm output.
-    setup_xfail "alpha*-*-osf*"
+    setup_xfail "alpha*-*-osf*" "sw_64*-*-ecoff*"
     setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
     setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
 
@@ -263,7 +263,7 @@ if [is_elf_format] {
     setup_xfail "sh*-*-*"
     # The pre-compiled dwarf info in dw4.s is not compatible with the
     # ALPHA, HPPA, IA64 and MIPS targets.
-    setup_xfail "alpha*-*-*" "hppa*-*-*" "ia64*-*-*" "mips*-*-*"
+    setup_xfail "alpha*-*-*" "sw_64*-*-*" "hppa*-*-*" "ia64*-*-*" "mips*-*-*"
     # Assembling the source file triggers an ICE in the FT32 assembler.
     # FIXME: Fix the ICE...
     setup_xfail "ft32-*-*"
@@ -303,7 +303,7 @@ if [is_elf_format] {
     # Test nm --ifunc-chars on a indirect symbols.
     
     # The following targets are known to not support ifuncs.
-    setup_xfail "alpha*-*-*"
+    setup_xfail "alpha*-*-*" "sw_64*-*-*"
     setup_xfail "arm*-elf" "arm*-*-nto*" "arm*-*-netbsdelf*"
     setup_xfail "*-*-hpux*"
     setup_xfail "mips*-*-*" "tx39*-*-*"
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index e1df9ff7..46bfd2a3 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -120,6 +120,7 @@ proc objcopy_test {testname srcfile type asflags ldflags} {
 
 	    # On OSF/1, this succeeds with gas and fails with /bin/as.
 	    setup_xfail "alpha*-*-osf*"
+            setup_xfail "sw_64*-*-osf*"
 
 	    fail "objcopy $type ($testname)"
 	}
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index c9a7eec7..81f82721 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -34,7 +34,7 @@ send_user "Version [binutil_version $OBJDUMP]"
 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
 
 set cpus_expected [list]
-lappend cpus_expected aarch64 alpha am33-2 arc ARC700 ARCv2 arm cris
+lappend cpus_expected aarch64 alpha sw_64 am33-2 arc ARC700 ARCv2 arm cris
 lappend cpus_expected d10v d30v fr30 fr500 fr550 h8 hppa i386 iamcu ip2022
 lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k MCore mep c5 h1 MicroBlaze
 lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 59e25df9..bd4119e1 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -1627,7 +1627,7 @@ proc get_standard_section_names {} {
     if [istarget "rx-*-elf"] {
 	return { "P" "D_1" "B_1" }
     }
-    if { [istarget "alpha*-*-*vms*"] || [is_som_format] } {
+    if { [istarget "alpha*-*-*vms*"] || [istarget "sw_64*-*-*vms*"] || [is_som_format] } {
 	return { {\$CODE\$} {\$DATA\$} {\$BSS\$} }
     }
     return
diff --git a/config.guess b/config.guess
index cc7a8107..9d4fbafa 100755
--- a/config.guess
+++ b/config.guess
@@ -355,6 +355,36 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	exitcode=$?
 	trap '' 0
 	exit $exitcode ;;
+    sw_64:OSF1:*:*)
+        case $UNAME_RELEASE in
+        *4.0)
+                UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+                ;;   
+        *5.*)
+                UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+                ;;   
+        esac 
+        # According to Compaq, /usr/sbin/psrinfo has been available on
+        # OSF/1 and Tru64 systems produced since 1995.  I hope that
+        # covers most systems running today.  This code pipes the CPU
+        # types through head -n 1, so we only detect the type of CPU 0.
+        SW_64_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The sw_64 \(.*\) processor.*$/\1/p' | head -n 1`
+        case "$SW_64_CPU_TYPE" in
+            "SW6A (21264)")
+                UNAME_MACHINE="sw_64sw6a" ;;
+            "SW6B (21264)")
+                UNAME_MACHINE="sw_64sw6b" ;;
+            "SW6 (21264A)")
+                UNAME_MACHINE="sw_64sw6" ;;
+        esac 
+        # A Pn.n version is a patched version.
+        # A Vn.n version is a released version.
+        # A Tn.n version is a released field test version.
+        # A Xn.n version is an unreleased experimental baselevel.
+        # 1.2 uses "1.2" for uname -r.
+        OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+        GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
+	;;
     Amiga*:UNIX_System_V:4.0:*)
 	echo m68k-unknown-sysv4
 	exit ;;
@@ -953,6 +983,16 @@ EOF
 	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
 	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
 	exit ;;
+    sw_64:Linux:*:*)
+        case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
+          SW6A)   UNAME_MACHINE=sw_64sw6a ;;
+          SW6B)   UNAME_MACHINE=sw_64sw6b ;;
+          SW6)  UNAME_MACHINE=sw_64sw6 ;;
+        esac
+        objdump --private-headers /bin/sh | grep -q ld.so.1
+        if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+	GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}
+	;;
     arc:Linux:*:* | arceb:Linux:*:* | arc64:Linux:*:*)
 	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
 	exit ;;
@@ -1474,6 +1514,7 @@ EOF
 	UNAME_MACHINE=$( (uname -p) 2>/dev/null)
 	case "$UNAME_MACHINE" in
 	    A*) echo alpha-dec-vms ; exit ;;
+	    S*) echo sw_64-dec-vms ; exit ;;
 	    I*) echo ia64-dec-vms ; exit ;;
 	    V*) echo vax-dec-vms ; exit ;;
 	esac ;;
diff --git a/config.sub b/config.sub
index 7384e919..f4fb2e2c 100755
--- a/config.sub
+++ b/config.sub
@@ -1163,6 +1163,7 @@ case $cpu-$vendor in
 			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
 			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
 			| alphapca5[67] | alpha64pca5[67] \
+                        | sw_64 | sw_64sw6a | sw_64sw6b \
 			| am33_2.0 \
 			| amdgcn \
 			| arc | arceb | arc64 \
diff --git a/config/elf.m4 b/config/elf.m4
index 1772a443..537373c3 100644
--- a/config/elf.m4
+++ b/config/elf.m4
@@ -17,7 +17,7 @@ target_elf=no
 case $target in
   *-darwin* | *-aix* | *-cygwin* | *-mingw* | *-aout* | *-*coff* | \
   *-msdosdjgpp* | *-vms* | *-wince* | *-*-pe* | \
-  alpha*-dec-osf* | *-interix* | hppa[[12]]*-*-hpux* | \
+  alpha*-dec-osf* | sw_64*-dec-osf* | *-interix* | hppa[[12]]*-*-hpux* | \
   nvptx-*-none)
     target_elf=no
     ;;
diff --git a/config/intdiv0.m4 b/config/intdiv0.m4
index 55dddcf1..8519d49e 100644
--- a/config/intdiv0.m4
+++ b/config/intdiv0.m4
@@ -56,7 +56,7 @@ int main ()
         [
           # Guess based on the CPU.
           case "$host_cpu" in
-            alpha* | i[34567]86 | m68k | s390*)
+            alpha* | sw_64* | i[34567]86 | m68k | s390*)
               gt_cv_int_divbyzero_sigfpe="guessing yes";;
             *)
               gt_cv_int_divbyzero_sigfpe="guessing no";;
diff --git a/config/picflag.m4 b/config/picflag.m4
index 8b106f9a..1397e3a1 100644
--- a/config/picflag.m4
+++ b/config/picflag.m4
@@ -20,6 +20,9 @@ case "${$2}" in
     alpha*-dec-osf5*)
 	# PIC is the default.
 	;;
+    sw_64*-dec-osf5*)
+	# PIC is the default.
+	;;
     hppa*64*-*-hpux*)
 	# PIC is the default for 64-bit PA HP-UX.
 	;;
diff --git a/config/tcl.m4 b/config/tcl.m4
index 4542a4b2..64319b54 100644
--- a/config/tcl.m4
+++ b/config/tcl.m4
@@ -1368,6 +1368,9 @@ dnl AC_CHECK_TOOL(AR, ar)
 	    if test "`uname -m`" = "alpha" ; then
 		CFLAGS="$CFLAGS -mieee"
 	    fi
+	    if test "`uname -m`" = "sw_64" ; then
+                CFLAGS="$CFLAGS -mieee"
+            fi
 	    if test $do64bit = yes; then
 		AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
 		    hold_cflags=$CFLAGS
@@ -1418,6 +1421,9 @@ dnl AC_CHECK_TOOL(AR, ar)
 	    if test "`uname -m`" = "alpha" ; then
 		CFLAGS="$CFLAGS -mieee"
 	    fi
+	    if test "`uname -m`" = "sw_64" ; then
+                CFLAGS="$CFLAGS -mieee"
+            fi
 	    ;;
 	Lynx*)
 	    SHLIB_CFLAGS="-fPIC"
diff --git a/configure b/configure
index 3dd20652..4c675f0a 100755
--- a/configure
+++ b/configure
@@ -778,6 +778,7 @@ ac_subst_files='serialization_dependencies
 host_makefile_frag
 target_makefile_frag
 alphaieee_frag
+sw_64ieee_frag
 ospace_frag'
 ac_user_opts='
 enable_option_checking
@@ -3013,7 +3014,7 @@ case "${ENABLE_GOLD}" in
       *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
       | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
       | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
-      | *-*-solaris2* | *-*-nto* | *-*-nacl*)
+      | *-*-solaris2* | *-*-nto* | *-*-nacl* | sw_64-*-*-*)
         case "${target}" in
           *-*-linux*aout* | *-*-linux*oldld*)
             ;;
@@ -3027,7 +3028,7 @@ case "${ENABLE_GOLD}" in
       # Check for target supported by gold.
       case "${target}" in
         i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \
-        | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-*)
+        | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-* | sw_64-*-*-*)
 	  configdirs="$configdirs gold"
 	  if test x${ENABLE_GOLD} = xdefault; then
 	    default_ld=gold
@@ -3436,6 +3437,9 @@ case "${target}" in
   alpha*-*-*vms*)
     noconfigdirs="$noconfigdirs target-libffi"
     ;;
+  sw_64*-*-*vms*)
+    noconfigdirs="$noconfigdirs target-libffi"
+    ;;
   arm*-*-freebsd*)
     noconfigdirs="$noconfigdirs target-libffi"
     ;;
@@ -3570,6 +3574,9 @@ case "${target}" in
   alpha*-dec-osf*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
+  sw_64*-dec-osf*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    ;;
   i[3456789]86-*-linux*)
     # This section makes it possible to build newlib natively on linux.
     # If we are using a cross compiler then don't configure newlib.
@@ -3702,6 +3709,18 @@ case "${target}" in
     # newlib is not 64 bit ready
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
+  sw_64*-dec-osf*)
+    # ld works, but does not support shared libraries.
+    # gas doesn't generate exception information.
+    noconfigdirs="$noconfigdirs gas ld"
+    ;;
+  sw_64*-*-*vms*)
+    noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
+    ;;
+  sw_64*-*-*)
+    # newlib is not 64 bit ready
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    ;;
   sh*-*-pe|mips*-*-pe|*arm-wince-pe)
     noconfigdirs="$noconfigdirs tcl tk itcl libgui sim"
     ;;
@@ -3965,6 +3984,9 @@ fi
   alpha*-linux*)
     host_makefile_frag="config/mh-alpha-linux"
     ;;
+  sw_64*-linux*)
+    host_makefile_frag="config/mh-sw_64-linux"
+    ;;
   hppa*-hp-hpux10*)
     host_makefile_frag="config/mh-pa-hpux10"
     ;;
@@ -6359,7 +6381,7 @@ target_elf=no
 case $target in
   *-darwin* | *-aix* | *-cygwin* | *-mingw* | *-aout* | *-*coff* | \
   *-msdosdjgpp* | *-vms* | *-wince* | *-*-pe* | \
-  alpha*-dec-osf* | *-interix* | hppa[12]*-*-hpux* | \
+  alpha*-dec-osf* | sw_64*-dec-osf* | *-interix* | hppa[12]*-*-hpux* | \
   nvptx-*-none)
     target_elf=no
     ;;
@@ -7292,6 +7314,15 @@ case $target in
     ;;
 esac
 
+sw_64ieee_frag=/dev/null
+case $target in
+  sw_64*-*-*)
+    # This just makes sure to use the -mieee option to build target libs.
+    # This should probably be set individually by each library.
+    sw_64ieee_frag="config/mt-sw_64ieee"
+    ;;
+esac
+
 # If --enable-target-optspace always use -Os instead of -O2 to build
 # the target libraries, similarly if it is not specified, use -Os
 # on selected platforms.
@@ -7996,7 +8027,7 @@ case "${target}" in
 esac
 
 # Makefile fragments.
-for frag in host_makefile_frag target_makefile_frag alphaieee_frag ospace_frag;
+for frag in host_makefile_frag target_makefile_frag alphaieee_frag sw_64ieee_frag ospace_frag;
 do
   eval fragval=\$$frag
   if test $fragval != /dev/null; then
diff --git a/configure.ac b/configure.ac
index 48f679b8..12b4c56c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,7 +336,7 @@ case "${ENABLE_GOLD}" in
       *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
       | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
       | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
-      | *-*-solaris2* | *-*-nto* | *-*-nacl*)
+      | *-*-solaris2* | *-*-nto* | *-*-nacl* | sw_64-*-*-*)
         case "${target}" in
           *-*-linux*aout* | *-*-linux*oldld*)
             ;;
@@ -350,7 +350,7 @@ case "${ENABLE_GOLD}" in
       # Check for target supported by gold.
       case "${target}" in
         i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \
-        | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-*)
+        | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-* | sw_64-*-*-*)
 	  configdirs="$configdirs gold"
 	  if test x${ENABLE_GOLD} = xdefault; then
 	    default_ld=gold
@@ -722,6 +722,9 @@ case "${target}" in
   alpha*-*-*vms*)
     noconfigdirs="$noconfigdirs target-libffi"
     ;;
+  sw_64*-*-*vms*)
+    noconfigdirs="$noconfigdirs target-libffi"
+    ;;
   arm*-*-freebsd*)
     noconfigdirs="$noconfigdirs target-libffi"
     ;;
@@ -853,6 +856,9 @@ case "${target}" in
   alpha*-dec-osf*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
+  sw_64*-dec-osf*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    ;;
   i[[3456789]]86-*-linux*)
     # This section makes it possible to build newlib natively on linux.
     # If we are using a cross compiler then don't configure newlib.
@@ -985,6 +991,18 @@ case "${target}" in
     # newlib is not 64 bit ready
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
+  sw_64*-dec-osf*)
+    # ld works, but does not support shared libraries.
+    # gas doesn't generate exception information.
+    noconfigdirs="$noconfigdirs gas ld"
+    ;;
+  sw_64*-*-*vms*)
+    noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
+    ;;
+  sw_64*-*-*)
+    # newlib is not 64 bit ready
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    ;;
   sh*-*-pe|mips*-*-pe|*arm-wince-pe)
     noconfigdirs="$noconfigdirs tcl tk itcl libgui sim"
     ;;
@@ -1229,6 +1247,9 @@ case "${host}" in
   alpha*-linux*)
     host_makefile_frag="config/mh-alpha-linux"
     ;;
+  sw_64*-linux*)
+    host_makefile_frag="config/mh-sw_64-linux"
+    ;;
   hppa*-hp-hpux10*)
     host_makefile_frag="config/mh-pa-hpux10"
     ;;
@@ -2608,6 +2629,15 @@ case $target in
     ;;
 esac
 
+sw_64ieee_frag=/dev/null
+case $target in
+  sw_64*-*-*)
+    # This just makes sure to use the -mieee option to build target libs.
+    # This should probably be set individually by each library.
+    sw_64ieee_frag="config/mt-sw_64ieee"
+    ;;
+esac
+
 # If --enable-target-optspace always use -Os instead of -O2 to build
 # the target libraries, similarly if it is not specified, use -Os
 # on selected platforms.
@@ -3307,7 +3337,7 @@ case "${target}" in
 esac
 
 # Makefile fragments.
-for frag in host_makefile_frag target_makefile_frag alphaieee_frag ospace_frag;
+for frag in host_makefile_frag target_makefile_frag alphaieee_frag sw_64ieee_frag ospace_frag;
 do
   eval fragval=\$$frag
   if test $fragval != /dev/null; then
@@ -3317,6 +3347,7 @@ done
 AC_SUBST_FILE(host_makefile_frag)
 AC_SUBST_FILE(target_makefile_frag)
 AC_SUBST_FILE(alphaieee_frag)
+AC_SUBST_FILE(sw_64ieee_frag)
 AC_SUBST_FILE(ospace_frag)
 
 # Miscellanea: directories, flags, etc.
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index fdee7ce3..98ea57ce 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -279,6 +279,7 @@ enum EM
   EM_FRV = 0x5441,
   // Infineon Technologies 16-bit microcontroller with C166-V2 core.
   EM_X16X = 0x4688,
+  EM_SW_64 = 0x9916,
   // Xstorym16
   EM_XSTORMY16 = 0xad45,
   // Renesas M32C
@@ -792,6 +793,7 @@ enum DT
   // symbol in the symbol table.
   DT_SPARC_REGISTER = 0x70000001,
 
+  DT_SW_64_PLTRO = 0x70000000,
   // MIPS specific dynamic array tags.
   // 32 bit version number for runtime linker interface.
   DT_MIPS_RLD_VERSION = 0x70000001,
diff --git a/gas/Makefile.am b/gas/Makefile.am
index 3ad8422d..6d7d981b 100644
--- a/gas/Makefile.am
+++ b/gas/Makefile.am
@@ -132,6 +132,7 @@ HFILES = \
 TARGET_CPU_CFILES = \
 	config/tc-aarch64.c \
 	config/tc-alpha.c \
+	config/tc-sw_64.c \
 	config/tc-arc.c \
 	config/tc-arm.c \
 	config/tc-avr.c \
@@ -207,6 +208,7 @@ TARGET_CPU_CFILES = \
 TARGET_CPU_HFILES = \
 	config/tc-aarch64.h \
 	config/tc-alpha.h \
+	config/tc-sw_64.h \
 	config/tc-arc.h \
 	config/tc-arm.h \
 	config/tc-avr.h \
diff --git a/gas/Makefile.in b/gas/Makefile.in
index 62439483..ba765d1c 100644
--- a/gas/Makefile.in
+++ b/gas/Makefile.in
@@ -521,6 +521,7 @@ HFILES = \
 TARGET_CPU_CFILES = \
 	config/tc-aarch64.c \
 	config/tc-alpha.c \
+	config/tc-sw_64.c \
 	config/tc-arc.c \
 	config/tc-arm.c \
 	config/tc-avr.c \
@@ -596,6 +597,7 @@ TARGET_CPU_CFILES = \
 TARGET_CPU_HFILES = \
 	config/tc-aarch64.h \
 	config/tc-alpha.h \
+	config/tc-sw_64.h \
 	config/tc-arc.h \
 	config/tc-arm.h \
 	config/tc-avr.h \
@@ -893,6 +895,8 @@ config/tc-aarch64.$(OBJEXT): config/$(am__dirstamp) \
 	config/$(DEPDIR)/$(am__dirstamp)
 config/tc-alpha.$(OBJEXT): config/$(am__dirstamp) \
 	config/$(DEPDIR)/$(am__dirstamp)
+config/tc-sw_64.$(OBJEXT): config/$(am__dirstamp) \
+	config/$(DEPDIR)/$(am__dirstamp)
 config/tc-arc.$(OBJEXT): config/$(am__dirstamp) \
 	config/$(DEPDIR)/$(am__dirstamp)
 config/tc-arm.$(OBJEXT): config/$(am__dirstamp) \
@@ -1160,6 +1164,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/rx-parse.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-aarch64.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-alpha.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-sw_64.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-arc.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-arm.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-avr.Po@am__quote@
diff --git a/gas/as.c b/gas/as.c
index 7de8af24..e32b4c2f 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -232,9 +232,10 @@ print_version_id (void)
   if (printed)
     return;
   printed = 1;
+  char *VERSION_SW="2.37-v1.0";
 
   fprintf (stderr, _("GNU assembler version %s (%s) using BFD version %s\n"),
-	   VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
+           VERSION_SW, TARGET_ALIAS, BFD_VERSION_STRING);
 }
 
 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
@@ -503,7 +504,8 @@ parse_args (int * pargc, char *** pargv)
       OPTION_WARN_FATAL,
       OPTION_COMPRESS_DEBUG,
       OPTION_NOCOMPRESS_DEBUG,
-      OPTION_NO_PAD_SECTIONS /* = STD_BASE + 40 */
+      OPTION_NO_PAD_SECTIONS, /* = STD_BASE + 40 */
+      OPTION_ORG_BACKWARDS
     /* When you add options here, check that they do
        not collide with OPTION_MD_BASE.  See as.h.  */
     };
@@ -581,6 +583,7 @@ parse_args (int * pargc, char *** pargv)
     ,{"target-help", no_argument, NULL, OPTION_TARGET_HELP}
     ,{"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT}
     ,{"warn", no_argument, NULL, OPTION_WARN}
+    ,{"pal", no_argument, NULL, OPTION_ORG_BACKWARDS}
   };
 
   /* Construct the option lists from the standard list and the target
@@ -683,6 +686,12 @@ parse_args (int * pargc, char *** pargv)
 	  flag_traditional_format = 1;
 	  break;
 
+#ifdef TARGET_SW_64
+        case OPTION_ORG_BACKWARDS:
+          pal_org_backwrards =1;
+          break;
+#endif
+
 	case OPTION_VERSION:
 	  /* This output is intended to follow the GNU standards document.  */
 	  printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
diff --git a/gas/as.h b/gas/as.h
index 14a768f8..98564652 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -344,6 +344,12 @@ COMMON int linkrelax;
 
 COMMON int do_not_pad_sections_to_alignment;
 
+#ifdef TARGET_SW_64
+/* Support -pal for hmcode.  */
+COMMON int pal_org_backwrards;
+#endif
+
+
 /* TRUE if we should produce a listing.  */
 extern int listing;
 
diff --git a/gas/config.in b/gas/config.in
index e243fd27..c68a0443 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -325,3 +325,12 @@
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+/* Default CPU for SW_64 targets. */
+#undef SW_CPU_STRING_DEFAULT
+
+/*Define Git verion for elf flags*/
+#undef GIT_REVISION
+
+#undef TARGET_SW_64
+
diff --git a/gas/config/obj-ecoff.c b/gas/config/obj-ecoff.c
index adc70778..e6156250 100644
--- a/gas/config/obj-ecoff.c
+++ b/gas/config/obj-ecoff.c
@@ -128,6 +128,16 @@ ecoff_frob_file_before_fix (void)
     fprmask = alpha_fprmask;
 #endif
 
+#ifdef TC_SW_64
+    sw_64_frob_ecoff_data ();
+
+    if (! bfd_ecoff_set_gp_value (stdoutput, sw_64_gp_value))
+      as_fatal (_("Can't set GP value"));
+
+    gprmask = sw_64_gprmask;
+    fprmask = sw_64_fprmask;
+#endif
+
     if (! bfd_ecoff_set_regmasks (stdoutput, gprmask, fprmask, cprmask))
       as_fatal (_("Can't set register masks"));
   }
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index e93d59cb..5e870c51 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -40,6 +40,12 @@
 #include "elf/alpha.h"
 #endif
 
+#ifdef TARGET_SW_64
+#ifdef TC_SW_64
+#include "elf/sw_64.h"
+#endif
+#endif
+
 #ifdef TC_MIPS
 #include "elf/mips.h"
 #endif
diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h
index d1fd3152..f54817fc 100644
--- a/gas/config/obj-elf.h
+++ b/gas/config/obj-elf.h
@@ -43,6 +43,11 @@
 extern int alpha_flag_mdebug;
 #endif
 
+#ifdef TC_SW_64
+#define ECOFF_DEBUGGING (sw_64_flag_mdebug > 0)
+extern int sw_64_flag_mdebug;
+#endif
+
 /* For now, always set ECOFF_DEBUGGING for a MIPS target.  */
 #ifdef TC_MIPS
 #define ECOFF_DEBUGGING mips_flag_mdebug
diff --git a/gas/configure b/gas/configure
index 73750257..40af0cf5 100755
--- a/gas/configure
+++ b/gas/configure
@@ -12188,6 +12188,25 @@ _ACEOF
 	;;
     esac
 
+    case ${cpu_type} in
+      sw_64 | sw_64sw*)
+        # Set sw_cpu to the name of the default CPU.
+	    sw_cpu=$with_cpu
+      cpu_types=${with_cpu:2:4}
+cat >>confdefs.h <<_ACEOF
+#define SW_CPU_STRING_DEFAULT "${with_cpu}"
+_ACEOF
+
+# Check for git version if there was a github
+git_version=`git log -1 --format="%h"`
+git_short=${git_version:0:5}${cpu_types}"9"
+cat >> confdefs.h <<_ACEOF
+#define GIT_REVISION 0x$git_short
+#define TARGET_SW_64
+_ACEOF
+        ;;
+    esac
+
     # Do we need the opcodes library?
     case ${cpu_type} in
       vax | tic30)
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 6272067d..b7b67073 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -49,6 +49,7 @@ case ${cpu} in
   aarch64)		cpu_type=aarch64 endian=little arch=aarch64;;
   aarch64_be)		cpu_type=aarch64 endian=big arch=aarch64;;
   alpha*)		cpu_type=alpha ;;
+  sw_64*)               cpu_type=sw_64 ;;
   am33_2.0)		cpu_type=mn10300 endian=little ;;
   arc*eb)		cpu_type=arc endian=big ;;
   arm*be|arm*b)		cpu_type=arm endian=big ;;
@@ -138,6 +139,13 @@ case ${generic_target} in
   alpha-*-linux-*)			fmt=elf em=linux ;;
   alpha-*-netbsd* | alpha-*-openbsd*)	fmt=elf em=nbsd ;;
 
+  sw_64-*-*vms*)                        fmt=evax ;;
+  sw_64-*-osf*)                         fmt=ecoff ;;
+  sw_64-*-linux*ecoff*)                 fmt=ecoff ;;
+  sw_64-*-linux-*)                      fmt=elf em=linux ;;
+  sw_64-*-netbsd*)                      fmt=elf em=nbsd ;;
+  sw_64-*-openbsd*)                     fmt=elf em=obsd ;;
+
   arc-*-elf*)				fmt=elf ;;
   arc*-*-linux*)			fmt=elf bfd_gas=yes ;;
 
@@ -435,7 +443,7 @@ esac
 
 case ${cpu_type} in
   aarch64 | alpha | arm | csky | i386 | ia64 | microblaze | mips | ns32k | \
-  or1k | or1knd | pdp11 | ppc | riscv | sh | sparc | z80 | z8k)
+  or1k | or1knd | pdp11 | ppc | riscv | sh | sparc | z80 | z8k | sw_64)
     bfd_gas=yes
     ;;
 esac
diff --git a/gas/read.c b/gas/read.c
index 584867dc..2ebb9c30 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -2520,7 +2520,7 @@ bss_alloc (symbolS *symbolP, addressT size, unsigned int align)
   subsegT current_subseg = now_subseg;
   segT bss_seg = bss_section;
 
-#if defined (TC_MIPS) || defined (TC_ALPHA)
+#if defined (TC_MIPS) || defined (TC_ALPHA) || defined (TC_SW_64)
   if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
       || OUTPUT_FLAVOR == bfd_target_elf_flavour)
     {
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 389634f6..fae2a2f2 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -57,6 +57,7 @@ if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
 # differences of two previously undefined symbols.  Hence this test will
 # not pass for these targets.
 if {    ![istarget alpha*-*-*vms*]
+     && ![istarget sw_64*-*-*vms*]
      && ![istarget am3*-*-*]
      && ![istarget avr-*-*]
      && ![istarget ft32-*-*]
@@ -120,6 +121,8 @@ if { ![is_aout_format] } {
 	}
 	alpha-*-*linux*ecoff { }
 	alpha-*-osf* { }
+        sw_64-*-*linux*ecoff { }
+	sw_64-*-osf* { }
 	hppa*-*-hpux* { }
 	mep-*-* { }
 	mmix-*-* { }
@@ -139,6 +142,7 @@ if { ![is_aout_format] } {
 # pdp11 gets unexpected reloc types.
 switch -glob $target_triplet {
     alpha*-*-* { }
+    sw_64*-*-* { }
     am3*-*-* { }
     cr16*-*-* { }
     crx*-*-* { }
@@ -360,6 +364,8 @@ proc test_cond {} {
 switch -glob $target_triplet {
     alpha-*-linux*ecoff { }
     alpha-*-osf* { }
+    sw_64-*-linux*ecoff { }
+    sw_64-*-osf* { }
     hppa*-*-* { }
     *c4x*-*-* { }
     *c54x*-*-* { }
@@ -431,6 +437,7 @@ if { ![istarget "pdp11-*-*"] } {
 # .set works differently on some targets.
 switch -glob $target_triplet {
     alpha*-*-* { }
+    sw_64*-*-* { }
     mips*-*-* { }
     *c54x*-*-* { }
     z80-*-* { }
diff --git a/gas/testsuite/gas/all/weakref1.d b/gas/testsuite/gas/all/weakref1.d
index 4c251640..895ec2d1 100644
--- a/gas/testsuite/gas/all/weakref1.d
+++ b/gas/testsuite/gas/all/weakref1.d
@@ -4,7 +4,8 @@
 # pdp11 lacks .long
 # darwin (mach-o) reverses the order of relocs.
 # the following must be present in all weakref1*.d
-#notarget: alpha*-*-osf* *-*-ecoff pdp11-*-aout *-*-darwin*
+#notarget: alpha*-*-osf* sw_64*-*-osf* *-*-ecoff pdp11-*-aout *-*-darwin*
+
 #xfail: nds32*-*-*
 
 #...
diff --git a/gas/testsuite/gas/all/weakref1g.d b/gas/testsuite/gas/all/weakref1g.d
index eb3f31d5..013d2521 100644
--- a/gas/testsuite/gas/all/weakref1g.d
+++ b/gas/testsuite/gas/all/weakref1g.d
@@ -4,7 +4,7 @@
 # see weakref1.d for comments on the notargets
 # ecoff (OSF/alpha) lacks .weak support
 # pdp11 lacks .long
-#notarget: alpha*-*-osf* *-*-ecoff pdp11-*-aout
+#notarget: alpha*-*-osf* sw_64*-*-osf* *-*-ecoff pdp11-*-aout
 
 # the rest of this file is generated with the following script:
 # # script begin
diff --git a/gas/testsuite/gas/all/weakref1l.d b/gas/testsuite/gas/all/weakref1l.d
index 3a42c00a..c573d215 100644
--- a/gas/testsuite/gas/all/weakref1l.d
+++ b/gas/testsuite/gas/all/weakref1l.d
@@ -3,7 +3,7 @@
 #source: weakref1.s
 # aix drops local symbols
 # see weakref1.d for comments on the other notargets
-#notarget: [is_xcoff_format] alpha*-*-osf* *-*-ecoff pdp11-*-aout
+#notarget: [is_xcoff_format] alpha*-*-osf* sw_64*-*-osf* *-*-ecoff pdp11-*-aout
 
 # the rest of this file is generated with the following script:
 # # script begin
diff --git a/gas/testsuite/gas/all/weakref1u.d b/gas/testsuite/gas/all/weakref1u.d
index 5b8d8489..ae3c2c6e 100644
--- a/gas/testsuite/gas/all/weakref1u.d
+++ b/gas/testsuite/gas/all/weakref1u.d
@@ -3,7 +3,7 @@
 #source: weakref1.s
 # aout turns undefined into *ABS* symbols.
 # see weakref1.d for comments on the other notargets
-#notarget: *-*-*aout ns32k-*-* alpha*-*-osf* *-*-ecoff
+#notarget: *-*-*aout ns32k-*-* alpha*-*-osf* sw_64*-*-osf* *-*-ecoff
 
 # the rest of this file is generated with the following script:
 # # script begin
diff --git a/gas/testsuite/gas/all/weakref1w.d b/gas/testsuite/gas/all/weakref1w.d
index 4cae455e..1333da0c 100644
--- a/gas/testsuite/gas/all/weakref1w.d
+++ b/gas/testsuite/gas/all/weakref1w.d
@@ -2,7 +2,7 @@
 #name: weakref tests, weak undefined syms
 #source: weakref1.s
 # see weakref1.d for comments on the notargets
-#notarget: alpha*-*-osf* *-*-ecoff pdp11-*-aout
+#notarget: alpha*-*-osf* sw_64*-*-osf* *-*-ecoff pdp11-*-aout
 
 # the rest of this file is generated with the following script:
 # # script begin
diff --git a/gas/testsuite/gas/elf/common5a.d b/gas/testsuite/gas/elf/common5a.d
index ec136b48..d5007fe2 100644
--- a/gas/testsuite/gas/elf/common5a.d
+++ b/gas/testsuite/gas/elf/common5a.d
@@ -3,3 +3,5 @@
 #error_output: common5a.l
 #notarget: alpha-*-*
 # The Alpha target uses its own .set pseudo-insn.
+#notarget: sw_64-*-*
+# The sw_64 target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5b.d b/gas/testsuite/gas/elf/common5b.d
index 9369c2df..3ad43996 100644
--- a/gas/testsuite/gas/elf/common5b.d
+++ b/gas/testsuite/gas/elf/common5b.d
@@ -3,3 +3,5 @@
 #error_output: common5b.l
 #notarget: alpha-*-*
 # The Alpha target uses its own .set pseudo-insn.
+#notarget: sw_64-*-*
+# The sw_64 target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5c.d b/gas/testsuite/gas/elf/common5c.d
index cbb3fc68..320f9486 100644
--- a/gas/testsuite/gas/elf/common5c.d
+++ b/gas/testsuite/gas/elf/common5c.d
@@ -3,3 +3,5 @@
 #error_output: common5a.l
 #notarget: alpha-*-*
 # The Alpha target uses its own .set pseudo-insn.
+#notarget: sw_64-*-*
+# The sw_64 target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5d.d b/gas/testsuite/gas/elf/common5d.d
index 7b11fa24..eb7e29a5 100644
--- a/gas/testsuite/gas/elf/common5d.d
+++ b/gas/testsuite/gas/elf/common5d.d
@@ -3,3 +3,5 @@
 #error_output: common5b.l
 #notarget: alpha-*-*
 # The Alpha target uses its own .set pseudo-insn.
+#notarget: sw_64-*-*
+# The sw_64 target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 23804758..271e3160 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -164,6 +164,7 @@ if { [is_elf_format] } then {
     }
     switch -glob $target_triplet {
 	alpha*-*-* { }
+        sw_64*-*-* { }
 	am3*-*-* { }
 	*c54x*-*-* { }
 	cr16*-*-* { }
@@ -216,7 +217,7 @@ if { [is_elf_format] } then {
 	run_elf_list_test "section5" "" "-al -Z" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
     }
     run_dump_test "struct"
-    if { ![istarget "alpha*-*-*"] } then {
+    if {! [istarget "alpha*-*-*"] && ! [istarget "sw_64*-*-*"]} then {
 	# The alpha port uses .set for state, e.g. nomacro.
 	run_dump_test "symtab"
     }
@@ -242,7 +243,10 @@ if { [is_elf_format] } then {
 	    run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
 	}
     } else {
-	run_dump_test ifunc-1
+        #if {! [istarget "sw_64*-*-*"] } then {
+	#    run_dump_test ifunc-1
+	#}
+        run_dump_test ifunc-1
 	run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
 	run_elf_list_test "type-2" "" "--warn" "-s" "| grep \"0 *\\\[FIONT\\\]\""
     }
@@ -308,6 +312,9 @@ if { [is_elf_format] } then {
     run_dump_test "bad-group"
     run_dump_test "pr27355"
 
+    #if { ![istarget "sw_64*-*-*"]} then {
+    #	run_dump_test "syms"
+    #}
     run_dump_test "syms"
     run_dump_test "startof"
 
@@ -322,6 +329,9 @@ if { [is_elf_format] } then {
 	run_dump_test "common3b"
 	run_dump_test "common4a"
 	run_dump_test "common4b"
+    }
+   
+    if { ![istarget "*-*-hpux*"]} then {
 	run_dump_test "common5a"
 	run_dump_test "common5b"
 	run_dump_test "common5c"
diff --git a/gas/testsuite/gas/elf/ifunc-1.d b/gas/testsuite/gas/elf/ifunc-1.d
index 5b2657b0..c558f2d2 100644
--- a/gas/testsuite/gas/elf/ifunc-1.d
+++ b/gas/testsuite/gas/elf/ifunc-1.d
@@ -1,6 +1,7 @@
 #readelf: -s
 #name: .set with IFUNC
 #notarget: alpha*
+#notarget: sw_64*
 
 #...
 [ 	]+[0-9]+:[ 	]+[0-9a-f]+[ 	]+[0-9]+[ 	]+IFUNC[ 	]+GLOBAL[ 	]+DEFAULT[ 	]+[1-9] __GI_foo
diff --git a/gas/testsuite/gas/elf/symtab.d b/gas/testsuite/gas/elf/symtab.d
index 68e5e7ca..7ab6c468 100644
--- a/gas/testsuite/gas/elf/symtab.d
+++ b/gas/testsuite/gas/elf/symtab.d
@@ -1,6 +1,7 @@
 # The Alpha has its own version of .set.
 # hppa SOM does not output non-global absolute symbols.
 #xfail: alpha-*-* [is_som_format]
+#xfail: sw_64-*-* [is_som_format]
 #readelf: -s
 #name: .set with expression
 
diff --git a/gas/write.c b/gas/write.c
index 7dc78b7f..0e2624e5 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -554,6 +554,53 @@ relax_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *xxx)
     info->changed = 1;
 }
 
+#ifdef TARGET_SW_64
+static void
+sort_frchain (frag_list)
+fragS *frag_list;
+{
+  fragS *fragp, *fragc, *fragi;
+  long r;
+  for (fragp = frag_list;fragp;)
+    {
+      fragc=fragp;
+      if (fragp->fr_next)
+	fragp = fragp->fr_next;
+      else
+	/* the end of the frag_list.  */
+	break;
+      r = ((long )fragp->fr_address - (long )fragc->fr_address - fragc->fr_fix) ;
+      if ( r < 0 )
+	{
+	  /*adjust the last fill frag's address ,but don't insert back,changed by WCH20080921.  */
+	  if (fragp->fr_type == rs_fill && fragp->fr_next == 0)
+	    {
+	      fragp->fr_address=fragp->last_fr_address=fragc->fr_address+
+	    fragc->fr_fix+fragc->fr_offset;
+	      continue;
+	    }
+	 
+	  fragc->fr_next = fragp->fr_next;
+	  for (fragi = frag_list; fragi != fragc; fragi=fragi->fr_next)
+	    {
+	      r = (fragi->fr_next->fr_address - fragp->fr_address - fragp->fr_fix) ;
+	      if (r >= 0)
+		{
+		  fragp->fr_next = fragi->fr_next;
+		  fragi->fr_next = fragp;
+		  fragp = fragc;
+		  break;
+		}
+	    }
+	  if (fragi == fragc)
+	    {
+	      as_bad_where (fragp->fr_file,fragp->fr_line,"ERR,can't insert the node!\n");
+	    }
+	}
+    }
+}
+#endif
+
 static void
 size_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *xxx ATTRIBUTE_UNUSED)
 {
@@ -566,6 +613,10 @@ size_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *xxx ATTRIBUTE_UNUSED)
   subseg_change (sec, 0);
 
   seginfo = seg_info (sec);
+#ifdef TARGET_SW_64
+  if (pal_org_backwrards)
+    sort_frchain (seginfo->frchainP->frch_root);
+#endif
   if (seginfo && seginfo->frchainP)
     {
       for (fragp = seginfo->frchainP->frch_root; fragp; fragp = fragp->fr_next)
@@ -2995,7 +3046,12 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)
 		  /* Growth may be negative, but variable part of frag
 		     cannot have fewer than 0 chars.  That is, we can't
 		     .org backwards.  */
-		  if ((offsetT) (address + fragP->fr_fix) > target)
+
+#ifdef TARGET_SW_64
+		  if (((offsetT) (address + fragP->fr_fix) > target) && !pal_org_backwrards)
+#else
+ 		  if ((offsetT) (address + fragP->fr_fix) > target)
+#endif
 		    {
 		      growth = 0;
 
diff --git a/gold/Makefile.am b/gold/Makefile.am
index 1947c18e..68dc49ce 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -173,13 +173,13 @@ diststuff: $(EXTRA_DIST)
 
 TARGETSOURCES = \
 	i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
-	mips.cc aarch64.cc aarch64-reloc-property.cc s390.cc
+	mips.cc aarch64.cc aarch64-reloc-property.cc s390.cc sw_64.cc
 
 ALL_TARGETOBJS = \
 	i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
 	arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \
 	mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT) \
-	s390.$(OBJEXT)
+	s390.$(OBJEXT) sw_64.$(OBJEXT)
 
 libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
 libgold_a_LIBADD = $(LIBOBJS)
diff --git a/gold/Makefile.in b/gold/Makefile.in
index 9fd21214..8c2557a0 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -792,13 +792,13 @@ DEFFILES = arm-reloc.def aarch64-reloc.def
 EXTRA_DIST = yyscript.c yyscript.h
 TARGETSOURCES = \
 	i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
-	mips.cc aarch64.cc aarch64-reloc-property.cc s390.cc
+	mips.cc aarch64.cc aarch64-reloc-property.cc s390.cc sw_64.cc
 
 ALL_TARGETOBJS = \
 	i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
 	arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \
 	mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT) \
-	s390.$(OBJEXT)
+	s390.$(OBJEXT) sw_64.$(OBJEXT)
 
 libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
 libgold_a_LIBADD = $(LIBOBJS)
@@ -1089,6 +1089,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapfile.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/merge.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mips.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sw_64.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nacl.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
diff --git a/gold/configure b/gold/configure
index b9f062b6..340b92f4 100755
--- a/gold/configure
+++ b/gold/configure
@@ -731,6 +731,8 @@ DEFAULT_TARGET_ARM_FALSE
 DEFAULT_TARGET_ARM_TRUE
 DEFAULT_TARGET_AARCH64_FALSE
 DEFAULT_TARGET_AARCH64_TRUE
+DEFAULT_TARGET_SW_64_FALSE
+DEFAULT_TARGET_SW_64_TRUE
 PLUGINS_FALSE
 PLUGINS_TRUE
 installed_linker
@@ -5318,6 +5320,14 @@ else
   DEFAULT_TARGET_MIPS_FALSE=
 fi
 
+         if test "$targ_obj" = "sw_64"; then
+  DEFAULT_TARGET_SW_64_TRUE=
+  DEFAULT_TARGET_SW_64_FALSE='#'
+else
+  DEFAULT_TARGET_SW_64_TRUE='#'
+  DEFAULT_TARGET_SW_64_FALSE=
+fi
+
 	DEFAULT_TARGET=${targ_obj}
 
       fi
@@ -10425,6 +10435,10 @@ if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
   as_fn_error $? "conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${DEFAULT_TARGET_SW_64_TRUE}" && test -z "${DEFAULT_TARGET_SW_64_FALSE}"; then
+  as_fn_error $? "conditional \"DEFAULT_TARGET_SW_64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
   as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/gold/configure.ac b/gold/configure.ac
index 1716a779..2f371724 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -239,6 +239,7 @@ for targ in $target $canon_targets; do
 		       test "$target_x86_64" = "yes" -o "$target_x32" = "yes")
 	AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx")
         AM_CONDITIONAL(DEFAULT_TARGET_MIPS, test "$targ_obj" = "mips")
+	AM_CONDITIONAL(DEFAULT_TARGET_SW_64, test "$targ_obj" = "sw_64")
 	DEFAULT_TARGET=${targ_obj}
 	AC_SUBST(DEFAULT_TARGET)
       fi
diff --git a/gold/configure.tgt b/gold/configure.tgt
index cac0866e..a32dd236 100644
--- a/gold/configure.tgt
+++ b/gold/configure.tgt
@@ -181,6 +181,12 @@ s390x-*-*)
  targ_big_endian=true
  targ_extra_big_endian=false
  ;;
+sw_64*-*-*)
+ targ_obj=sw_64
+ targ_machine=EM_SW_64
+ targ_size=64
+ targ_big_endian=false
+ ;;
 *)
   targ_obj=UNKNOWN
   ;;
diff --git a/gold/reloc.h b/gold/reloc.h
index 5f1d382a..0b7f0e5b 100644
--- a/gold/reloc.h
+++ b/gold/reloc.h
@@ -239,6 +239,7 @@ class Relocatable_relocs
     RELOC_ADJUST_FOR_SECTION_RELA,
     // Like RELOC_ADJUST_FOR_SECTION_RELA but the addend should not be
     // adjusted.
+    RELOC_ADJUST_FOR_SECTION_RELA_0,
     RELOC_ADJUST_FOR_SECTION_0,
     // Like RELOC_ADJUST_FOR_SECTION_RELA but the contents of the
     // section need to be changed.  The number indicates the number of
diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index cd40bcc0..7f00f93d 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -845,6 +845,7 @@ relocate_relocs(
 	      break;
 
 	    case Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA:
+	    case Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA_0:
 	    case Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_0:
 	    case Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_1:
 	    case Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_2:
@@ -916,7 +917,8 @@ relocate_relocs(
 
       // Handle the reloc addend based on the strategy.
 
-      if (strategy == Relocatable_relocs::RELOC_COPY)
+      if (strategy == Relocatable_relocs::RELOC_COPY
+	 || Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA_0 == strategy)
 	{
 	  if (Classify_reloc::sh_type == elfcpp::SHT_RELA)
 	    Classify_reloc::put_r_addend(&reloc_write,
diff --git a/include/coff/ecoff.h b/include/coff/ecoff.h
index 2267b779..ae54eeea 100644
--- a/include/coff/ecoff.h
+++ b/include/coff/ecoff.h
@@ -47,6 +47,20 @@
 /* A compressed version of an ALPHA_MAGIC file created by DEC's tools.  */
 #define ALPHA_MAGIC_COMPRESSED 0x188
 
+#ifdef TARGET_SW_64
+/* Sw_64 magic numbers used in filehdr.  */
+#define SW_64_MAGIC 0x184
+#define SW_64_MAGIC_BSD 0x187
+/* A compressed version of an SW_64_MAGIC file created by DEC's tools.  */
+#define SW_64_MAGIC_COMPRESSED 0x189
+#endif
+
+/* Alpha magic numbers used in filehdr.  */
+#define SW_64_MAGIC 0x184
+#define SW_64_MAGIC_BSD 0x187
+/* A compressed version of an ALPHA_MAGIC file created by DEC's tools.  */
+#define SW_64_MAGIC_COMPRESSED 0x189
+
 /* Magic numbers used in a.out header.  */
 #define ECOFF_AOUT_OMAGIC 0407	/* not demand paged (ld -N).  */
 #define ECOFF_AOUT_ZMAGIC 0413	/* demand load format, eg normal ld output */
diff --git a/include/coff/pe.h b/include/coff/pe.h
index 558cf0e1..b19307a4 100644
--- a/include/coff/pe.h
+++ b/include/coff/pe.h
@@ -134,6 +134,10 @@
 #define IMAGE_FILE_MACHINE_UNKNOWN           0x0000
 #define IMAGE_FILE_MACHINE_ALPHA             0x0184
 #define IMAGE_FILE_MACHINE_ALPHA64           0x0284
+#ifdef TARGET_SW_64
+#define IMAGE_FILE_MACHINE_SW_64             0x0184
+#define IMAGE_FILE_MACHINE_SW_6464           0x0284
+#endif
 #define IMAGE_FILE_MACHINE_AM33              0x01d3
 #define IMAGE_FILE_MACHINE_AMD64             0x8664
 #define IMAGE_FILE_MACHINE_ARM               0x01c0
diff --git a/include/elf/common.h b/include/elf/common.h
index 0cca2867..be66b736 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -409,6 +409,11 @@
 /* Alpha backend magic number.  Written in the absence of an ABI.  */
 #define EM_ALPHA		0x9026
 
+#ifdef TARGET_SW_64
+/* Sw_64 backend magic number.  Written in the absence of an ABI.  */
+#define EM_SW_64                0x9916
+#endif
+
 /* Cygnus M32R ELF backend.  Written in the absence of an ABI.  */
 #define EM_CYGNUS_M32R		0x9041
 
diff --git a/include/longlong.h b/include/longlong.h
index c3e92e54..f1997361 100644
--- a/include/longlong.h
+++ b/include/longlong.h
@@ -191,6 +191,61 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 #endif /* __alpha_cix__ */
 #endif /* __alpha */
 
+//__sw_64_cix__
+#if defined (__sw_64) && W_TYPE_SIZE == 64
+/* There is a bug in g before version 5 that
+   errors on __builtin_sw_64_umulh.  */
+#if !defined(__cplusplus) || __GNUC__ >= 5
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {									\
+    UDItype __m0 = (m0), __m1 = (m1);					\
+    (ph) = __builtin_sw_64_umulh (__m0, __m1);				\
+    (pl) = __m0 * __m1;							\
+  } while (0)
+#define UMUL_TIME 46
+#endif /* !c */
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  do { UDItype __r;							\
+    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));				\
+    (r) = __r;								\
+  } while (0)
+extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
+#define UDIV_TIME 220
+#endif /* LONGLONG_STANDALONE */
+#ifdef __sw_64_cix__
+#define count_leading_zeros(COUNT,X)	((COUNT) = __builtin_clzl (X))
+#define count_trailing_zeros(COUNT,X)	((COUNT) = __builtin_ctzl (X))
+#define COUNT_LEADING_ZEROS_0 64
+#else
+#define count_leading_zeros(COUNT,X) \
+  do {									\
+    UDItype __xr = (X), __t, __a;					\
+    __t = __builtin_sw_64_cmpbge (0, __xr);				\
+    __a = __clz_tab[__t ^ 0xff] - 1;					\
+    __t = __builtin_sw_64_extbl (__xr, __a);				\
+    (COUNT) = 64 - (__clz_tab[__t]  __a*8);				\
+  } while (0)
+#define count_trailing_zeros(COUNT,X) \
+  do {									\
+    UDItype __xr = (X), __t, __a;					\
+    __t = __builtin_sw_64_cmpbge (0, __xr);				\
+    __t = ~__t & -~__t;							\
+    __a = ((__t & 0xCC) != 0) * 2;					\
+    __a = ((__t & 0xF0) != 0) * 4;					\
+    __a = ((__t & 0xAA) != 0);						\
+    __t = __builtin_sw_64_extbl (__xr, __a);				\
+    __a <<= 3;								\
+    __t &= -__t;							\
+    __a = ((__t & 0xCC) != 0) * 2;					\
+    __a = ((__t & 0xF0) != 0) * 4;					\
+    __a = ((__t & 0xAA) != 0);						\
+    (COUNT) = __a;							\
+  } while (0)
+#endif /* __sw_64_cix__ */
+#endif /* __sw_64 */
+//sw_64
+
 #if defined (__arc__) && W_TYPE_SIZE == 32
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
   __asm__ ("add.f	%1, %4, %5\n\tadc	%0, %2, %3"		\
diff --git a/ld/Makefile.am b/ld/Makefile.am
index d912d265..37a73df0 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -159,6 +159,8 @@ ALL_EMULATION_SOURCES = \
 	eaixrs6.c \
 	ealpha.c \
 	ealphavms.c \
+	esw_64.c \
+	esw_64vms.c \
 	earcv2elf.c \
 	earcv2elfx.c \
 	earcelf.c \
@@ -429,6 +431,9 @@ ALL_64_EMULATION_SOURCES = \
 	eelf64alpha.c \
 	eelf64alpha_fbsd.c \
 	eelf64alpha_nbsd.c \
+	eelf64sw_64.c \
+	eelf64sw_64_fbsd.c \
+	eelf64sw_64_nbsd.c \
 	eelf64bmip.c \
 	eelf64btsmip.c \
 	eelf64btsmip_fbsd.c \
@@ -649,6 +654,8 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixrs6.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealpha.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealphavms.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esw_64.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esw_64vms.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcv2elf.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcv2elfx.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcelf.Pc@am__quote@
@@ -915,6 +922,9 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha_fbsd.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha_nbsd.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64_fbsd.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64_nbsd.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64bmip.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip_fbsd.Pc@am__quote@
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 4e88d0ec..ad27dc3e 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -648,6 +648,8 @@ ALL_EMULATION_SOURCES = \
 	eaixrs6.c \
 	ealpha.c \
 	ealphavms.c \
+	esw_64.c \
+	esw_64vms.c \
 	earcv2elf.c \
 	earcv2elfx.c \
 	earcelf.c \
@@ -917,6 +919,9 @@ ALL_64_EMULATION_SOURCES = \
 	eelf64alpha.c \
 	eelf64alpha_fbsd.c \
 	eelf64alpha_nbsd.c \
+	eelf64sw_64.c \
+	eelf64sw_64_fbsd.c \
+	eelf64sw_64_nbsd.c \
 	eelf64bmip.c \
 	eelf64btsmip.c \
 	eelf64btsmip_fbsd.c \
@@ -1252,6 +1257,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixrs6.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealpha.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealphavms.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esw_64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esw_64vms.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcelf.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earclinux.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earclinux_nps.Po@am__quote@
@@ -1409,6 +1416,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha_fbsd.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha_nbsd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64_fbsd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64_nbsd.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64bmip.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64bpf.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64briscv.Po@am__quote@
@@ -2306,6 +2316,8 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixrs6.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealpha.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealphavms.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esw_64.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esw_64vms.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcv2elf.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcv2elfx.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcelf.Pc@am__quote@
@@ -2572,6 +2584,11 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha_fbsd.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64alpha_nbsd.Pc@am__quote@
+#ifndef LIJM20201117
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64_fbsd.Pc@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64sw_64_nbsd.Pc@am__quote@
+#endif
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64bmip.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip.Pc@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip_fbsd.Pc@am__quote@
diff --git a/ld/config.in b/ld/config.in
index 26d55a00..173f2348 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -241,3 +241,5 @@
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+#undef TARGET_SW_64
diff --git a/ld/configure b/ld/configure
index e287d291..06d7ab1f 100755
--- a/ld/configure
+++ b/ld/configure
@@ -15376,6 +15376,13 @@ else
 esac
 fi
 
+case "${target}" in
+  sw_64-*-*)
+cat >>confdefs.h <<_ACEOF
+#define TARGET_SW_64
+_ACEOF
+  ;;
+  esac
 
 case "${enable_default_hash_style}" in
   sysv | both) ac_default_emit_sysv_hash=1 ;;
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 8b577f21..269f7fd4 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -102,6 +102,19 @@ alpha*-*-openbsd*)	targ_emul=elf64alpha
 alpha*-*-*vms*)		targ_emul=alphavms
 			targ_extra_ofiles=
 			;;
+sw_64*-*-linux-* | sw_64*-*-gnu*)
+        case "${targ}" in
+            sw_64sw6a*)
+                targ_emul=elf64sw_64 targ_extra_emuls=sw_64
+                tdir_sw_64=`echo ${targ_alias} | sed -e 's/linux\(-gnu\)*/linux\1ecoff/'` ;;
+            sw_64sw6b*)
+                targ_emul=elf64sw_64 targ_extra_emuls=sw_64
+                tdir_sw_64=`echo ${targ_alias} | sed -e 's/linux\(-gnu\)*/linux\1ecoff/'` ;;
+            *)
+                targ_emul=elf64sw_64 targ_extra_emuls=sw_64
+                tdir_sw_64=`echo ${targ_alias} | sed -e 's/linux\(-gnu\)*/linux\1ecoff/'` ;;
+        esac
+        ;;
 am33_2.0-*-linux*)	targ_emul=elf32am33lin # mn10300 variant
 			;;
 arc*-*-elf*)		targ_emul=arcelf
@@ -1085,6 +1098,9 @@ alpha*-*-*)
   NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
   ;;
 
+sw_64*-*-*)
+  NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
+  ;;
 esac
 
 case "${target}" in
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 0795ea81..d0cce3a9 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -434,6 +434,26 @@ if { [istarget alpha*-*-*vms*] } {
     unset f src
 }
 
+# Provide dummy libraries that sw_64-vms-ld always loads
+if { [istarget sw_64*-*-*vms*] } {
+    set src tmpdir/empty.s
+    set f [open $src "w"]
+    close $f
+    if { [ld_assemble $as $src tmpdir/empty.o]
+	 && ![ld_link $LD tmpdir/empty tmpdir/empty.o]
+	 && [regsub -all {[^\n]*: cannot find -l([^\n]*)} $exec_output {tmpdir/lib\1.a } missing_libs] } {
+	regsub -all {\$} $missing_libs {\\\$} missing_libs
+	for { set i 0 } { $i < [llength $missing_libs] } { incr i } {
+	    set f [lindex $missing_libs $i]
+	    verbose -log "creating dummy $f"
+	    ar_simple_create $ar {} $f tmpdir/empty.o
+	}
+	append LDFLAGS " -Ltmpdir"
+	unset i missing_libs
+    }
+    unset f src
+}
+
 set plug_opt ""
 if { [check_compiler_available] } {
     set plugin_names {
diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
index 426f3293..f94d79e5 100644
--- a/ld/testsuite/ld-elf/binutils.exp
+++ b/ld/testsuite/ld-elf/binutils.exp
@@ -88,6 +88,7 @@ proc binutils_test { prog_name ld_options test {test_name ""} {readelf_options "
 	# These targets do not set NO_SMALL_DATA or DATA_GOT and therefore
 	# have `.got' in (read-write) small data rather than regular data.
 	set relro_got [expr !([istarget "alpha*-*-*"] \
+                              || [istarget "sw_64*-*-*"] \
 			      || [istarget "hppa*-*-linux-*"] \
 			      || [istarget "hppa*-*-netbsd*"] \
 			      || [istarget "hppa*-*-openbsd*"] \
diff --git a/ld/testsuite/ld-elf/compress1a.d b/ld/testsuite/ld-elf/compress1a.d
index 0d5b68e7..f97b18b7 100644
--- a/ld/testsuite/ld-elf/compress1a.d
+++ b/ld/testsuite/ld-elf/compress1a.d
@@ -2,7 +2,7 @@
 #as: --compress-debug-sections
 #ld: -e func_cu2
 #readelf: -S --wide
-#xfail: alpha-*-*ecoff
+#xfail: alpha-*-*ecoff sw_64-*-*ecoff
 
 #failif
 #...
diff --git a/ld/testsuite/ld-elf/compressed1a.d b/ld/testsuite/ld-elf/compressed1a.d
index 3a5572ec..6780e319 100644
--- a/ld/testsuite/ld-elf/compressed1a.d
+++ b/ld/testsuite/ld-elf/compressed1a.d
@@ -2,7 +2,7 @@
 #as: --compress-debug-sections=zlib-gabi
 #ld: -e func_cu2
 #readelf: -t
-#xfail: alpha-*-*ecoff
+#xfail: alpha-*-*ecoff sw_64-*-*ecoff
 
 #failif
 #...
diff --git a/ld/testsuite/ld-elf/eh5.d b/ld/testsuite/ld-elf/eh5.d
index 4a697482..eff6e961 100644
--- a/ld/testsuite/ld-elf/eh5.d
+++ b/ld/testsuite/ld-elf/eh5.d
@@ -4,7 +4,7 @@
 #ld:
 #readelf: -wf
 #target: [check_as_cfi]
-#xfail: alpha-*-*ecoff hppa64-*-* tile*-*-* visium-*-*
+#xfail: alpha-*-*ecoff sw_64-*-*ecoff hppa64-*-* tile*-*-* visium-*-*
 
 Contents of the .eh_frame section:
 
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index e98bffc0..1c192537 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -51,7 +51,7 @@ if [istarget "*-*-hpux*"] {
     set ASFLAGS "$ASFLAGS --defsym HPUX=1"
 }
 
-if { [istarget alpha*-*-* ] } {
++if { [istarget alpha*-*-* ] || [istarget sw_64*-*-*]} {
     # The compress1 test is written expecting 32-bit addresses; force the
     # executable down into the low address space to match.
     # ??? How can we adjust just the one testcase?
diff --git a/ld/testsuite/ld-elf/pr17550a.d b/ld/testsuite/ld-elf/pr17550a.d
index 752c3ad6..33581821 100644
--- a/ld/testsuite/ld-elf/pr17550a.d
+++ b/ld/testsuite/ld-elf/pr17550a.d
@@ -3,7 +3,7 @@
 #ld: -r
 #readelf: -s --wide
 # Disabled on alpha because alpha has a different .set directive.
-#xfail: alpha-*-*
+#xfail: alpha-*-* sw_64-*-*
 
 #failif
 #...
diff --git a/ld/testsuite/ld-elf/pr17550b.d b/ld/testsuite/ld-elf/pr17550b.d
index 09e7ddfe..bf80e9fa 100644
--- a/ld/testsuite/ld-elf/pr17550b.d
+++ b/ld/testsuite/ld-elf/pr17550b.d
@@ -3,7 +3,7 @@
 #ld: -r
 #readelf: -s --wide
 # Disabled on alpha because alpha has a different .set directive.
-#xfail: alpha-*-*
+#xfail: alpha-*-* sw_64-*-*
 
 #failif
 #...
diff --git a/ld/testsuite/ld-elf/pr17550c.d b/ld/testsuite/ld-elf/pr17550c.d
index 55749fc7..97c394c1 100644
--- a/ld/testsuite/ld-elf/pr17550c.d
+++ b/ld/testsuite/ld-elf/pr17550c.d
@@ -5,3 +5,6 @@
 #xfail: alpha-*-* [is_generic]
 # Disabled on alpha because alpha has a different .set directive.
 # Generic linker targets don't support comdat group sections.
+#xfail: sw_64-*-* [is_generic]
+# Disabled on sw_64 because sw_64 has a different .set directive.
+# Generic linker targets don't support comdat group sections.
diff --git a/ld/testsuite/ld-elf/pr17550d.d b/ld/testsuite/ld-elf/pr17550d.d
index 3dd108d5..f0b2ea72 100644
--- a/ld/testsuite/ld-elf/pr17550d.d
+++ b/ld/testsuite/ld-elf/pr17550d.d
@@ -5,6 +5,9 @@
 # Disabled on alpha because alpha has a different .set directive.
 # Generic linker targets don't support comdat group sections.
 #xfail: alpha-*-* [is_generic]
+# Disabled on sw_64 because sw_64 has a different .set directive.
+# Generic linker targets don't support comdat group sections.
+#xfail: sw_64-*-* [is_generic]
 
 #...
  +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +UND y
diff --git a/ld/testsuite/ld-elf/pr18720b.c b/ld/testsuite/ld-elf/pr18720b.c
index 6b3222db..826a17a1 100644
--- a/ld/testsuite/ld-elf/pr18720b.c
+++ b/ld/testsuite/ld-elf/pr18720b.c
@@ -9,6 +9,8 @@ foo (void)
 __asm__ (".symver foo,foo@FOO");
 #ifdef __alpha__
 __asm__ ("foo_alias = foo");
+#elif __sw_64__
+__asm__ ("foo_alias = foo");
 #else
 __asm__ (".set foo_alias,foo");
 #endif
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index d00358e4..f1e6e1be 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -346,6 +346,7 @@ if { [check_gc_sections_available] } {
 	mips*-*-* { }
 	tic6x-*-* { }
 	xtensa-*-* { }
+        sw_64-*-* { }
 	default {
 	    run_ld_link_tests [list \
 		[list \
@@ -464,7 +465,8 @@ run_ld_link_tests [list \
 ]
 
 # These targets don't copy dynamic variables into .bss.
-setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
+# setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
+setup_xfail "sw_64-*-*" "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
 # or don't have .data.rel.ro
 setup_xfail "hppa*64*-*-hpux*" "tic6x-*-*"
 # or complain about relocs in read-only sections
@@ -484,7 +486,8 @@ run_ld_link_tests [list \
 	{pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \
 ] {![check_relro_support]}
 
-setup_xfail alpha-*-* xtensa-*-*
+# setup_xfail alpha-*-* xtensa-*-*
+setup_xfail sw_64-*-* alpha-*-* xtensa-*-*
 run_ld_link_tests [list \
     [list \
 	"pr20995-2" \
@@ -500,7 +503,8 @@ run_ld_link_tests [list \
 # The next test checks that copy relocs are not used unnecessarily,
 # but that is just an optimization so don't complain loudly.
 setup_xfail *-*-*
-clear_xfail alpha-*-* bfin-*-linux* csky-*-* frv-*-* hppa*-*-* i?86-*-*
+# clear_xfail alpha-*-* bfin-*-linux* csky-*-* frv-*-* hppa*-*-* i?86-*-*
+clear_xfail sw_64-*-* alpha-*-* bfin-*-linux* csky-*-* frv-*-* hppa*-*-* i?86-*-*
 clear_xfail ia64-*-* microblaze-*-* powerpc*-*-* x86_64-*-* xtensa-*-*
 run_ld_link_tests {
     {"pr22374 function pointer initialization"
@@ -871,7 +875,8 @@ run_cc_link_tests [list \
 ]
 
 # pr19073.s uses .set, which has a different meaning on alpha.
-if { ![istarget alpha-*-*] } {
+# if { ![istarget alpha-*-*] } {
+if { ![istarget alpha-*-*] && ![istarget sw_64-*-*] } {
     append build_tests {
 	{"Build pr19073a.o"
 	 "-r -nostdlib" ""
diff --git a/ld/testsuite/ld-elf/stab.d b/ld/testsuite/ld-elf/stab.d
index 27b99cb3..97d76d93 100644
--- a/ld/testsuite/ld-elf/stab.d
+++ b/ld/testsuite/ld-elf/stab.d
@@ -2,7 +2,7 @@
 #as: -gstabs
 #readelf: -S --wide
 #ld:
-#notarget: "ia64-*-*" "alpha*"
+#notarget: "ia64-*-*" "alpha*" "sw_64*"
 
 # Disabled on alpha because the entry point may be above 4GB but the stabs
 # value only 32 bits.
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
index 8a1383fe..b49b27f8 100644
--- a/ld/testsuite/ld-elfvers/vers.exp
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -51,6 +51,7 @@ if { ![istarget hppa*64*-*-hpux*]
      && ![istarget arm*-*-linux*]
      && ![istarget mips*-*-linux*]
      && ![istarget alpha*-*-linux*]
+     && ![istarget sw_64*-*-linux*]
      && ![istarget s390*-*-linux*]
      && ![istarget sh\[34\]*-*-linux*]
      && ![istarget x86_64-*-linux*] } {
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
index ee73cfe8..5030b102 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.exp
+++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
@@ -42,6 +42,7 @@ if { ![istarget hppa*64*-*-hpux*] \
      && ![istarget powerpc*-*-linux*] \
      && ![istarget arm*-*-linux*] \
      && ![istarget alpha*-*-linux*] \
+     && ![istarget sw_64*-*-linux*] \
      && ![istarget sparc*-*-linux*] \
      && ![istarget s390*-*-linux*] \
      && ![istarget sh\[34\]*-*-linux*] \
@@ -267,6 +268,7 @@ proc visibility_run {visibility} {
 		 && ![ string match $visibility "protected_undef" ] } {
 		setup_xfail "ia64-*-linux*"
 		setup_xfail "alpha*-*-linux*"
+                setup_xfail "sw_64*-*-linux*"
 	    }
 	    if { ![ string match $visibility "hidden" ]
 		 && ![ string match $visibility "hidden_undef" ]
@@ -316,6 +318,7 @@ proc visibility_run {visibility} {
 		 && ![ string match $visibility "protected_undef" ] } {
 		setup_xfail "ia64-*-linux*"
 		setup_xfail "alpha*-*-linux*"
+                setup_xfail "sw_64*-*-linux*"
 		setup_xfail "mips*-*-linux*"
 	    }
 	    if { [is_elf64 $tmpdir/mainnp.o] } {
@@ -372,6 +375,7 @@ proc visibility_run {visibility} {
 		 && ![ string match $visibility "protected_undef" ] } {
 		setup_xfail "ia64-*-linux*"
 		setup_xfail "alpha*-*-linux*"
+                setup_xfail "sw_64*-*-linux*"
 	    }
 	    if { ![ string match $visibility "hidden" ]
 		 && ![ string match $visibility "hidden_undef" ]
diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
index 56949d74..bd208d46 100644
--- a/ld/testsuite/ld-elfweak/elfweak.exp
+++ b/ld/testsuite/ld-elfweak/elfweak.exp
@@ -31,6 +31,7 @@ if { ![check_compiler_available] } {
 # Square bracket expressions seem to confuse istarget.
 # This is similar to the test that is used in ld-shared, BTW.
 if {    ![istarget alpha*-*-linux*]
+     && ![istarget sw_64*-*-linux*]
      && ![istarget arm*-*-linux*]
      && ![istarget hppa*64*-*-hpux*]
      && ![istarget hppa*-*-linux*]
diff --git a/ld/testsuite/ld-ifunc/ifunc-26.d b/ld/testsuite/ld-ifunc/ifunc-26.d
index 05e380a8..156f85b4 100644
--- a/ld/testsuite/ld-ifunc/ifunc-26.d
+++ b/ld/testsuite/ld-ifunc/ifunc-26.d
@@ -1,6 +1,6 @@
 #ld: -shared
 #readelf: -h
-#xfail: alpha-*-*
+#xfail: alpha-*-* sw_64-*-*
 
 ELF Header:
 #...
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index 45b47d7d..f66a53f4 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -25,6 +25,7 @@
 
 if { ![is_elf_format] || ![supports_gnu_osabi]
      || [istarget alpha-*-*]
+     || [istarget sw_64*-*-*]
      || [istarget arc*-*-*]
      || [istarget am33*-*-*]
      || [istarget bfin-*-*]
diff --git a/ld/testsuite/ld-misc/just-symbols.exp b/ld/testsuite/ld-misc/just-symbols.exp
index 51029147..1506c105 100644
--- a/ld/testsuite/ld-misc/just-symbols.exp
+++ b/ld/testsuite/ld-misc/just-symbols.exp
@@ -26,7 +26,8 @@
 if { [istarget sh-*-pe]
      || [istarget *-*-msdos]
      || [istarget *c30-*-*]
-     || [istarget alpha-*-vms] } {
+     || [istarget alpha-*-vms]
+     || [istarget sw_64-*-vms] } {
     return
 }
 
diff --git a/ld/testsuite/ld-plugin/plugin-14.d b/ld/testsuite/ld-plugin/plugin-14.d
index 81365af7..6c2db663 100644
--- a/ld/testsuite/ld-plugin/plugin-14.d
+++ b/ld/testsuite/ld-plugin/plugin-14.d
@@ -29,5 +29,6 @@ hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 hook called: all symbols read.
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
 #...
diff --git a/ld/testsuite/ld-plugin/plugin-15.d b/ld/testsuite/ld-plugin/plugin-15.d
index 02c5e60b..ef13000a 100644
--- a/ld/testsuite/ld-plugin/plugin-15.d
+++ b/ld/testsuite/ld-plugin/plugin-15.d
@@ -30,5 +30,6 @@ hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 hook called: all symbols read.
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
 #...
diff --git a/ld/testsuite/ld-plugin/plugin-16.d b/ld/testsuite/ld-plugin/plugin-16.d
index 504fbdbc..5d816efb 100644
--- a/ld/testsuite/ld-plugin/plugin-16.d
+++ b/ld/testsuite/ld-plugin/plugin-16.d
@@ -34,5 +34,6 @@ Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
 #...
diff --git a/ld/testsuite/ld-plugin/plugin-20.d b/ld/testsuite/ld-plugin/plugin-20.d
index 31bc3766..3c3d53eb 100644
--- a/ld/testsuite/ld-plugin/plugin-20.d
+++ b/ld/testsuite/ld-plugin/plugin-20.d
@@ -4,4 +4,5 @@ Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-21.d b/ld/testsuite/ld-plugin/plugin-21.d
index 0b85f715..cc87440a 100644
--- a/ld/testsuite/ld-plugin/plugin-21.d
+++ b/ld/testsuite/ld-plugin/plugin-21.d
@@ -4,4 +4,5 @@ Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-22.d b/ld/testsuite/ld-plugin/plugin-22.d
index 1084a0b0..51a335bb 100644
--- a/ld/testsuite/ld-plugin/plugin-22.d
+++ b/ld/testsuite/ld-plugin/plugin-22.d
@@ -4,4 +4,5 @@ Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-23.d b/ld/testsuite/ld-plugin/plugin-23.d
index 0b6c25c1..14bb8a60 100644
--- a/ld/testsuite/ld-plugin/plugin-23.d
+++ b/ld/testsuite/ld-plugin/plugin-23.d
@@ -4,4 +4,5 @@ Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-6.d b/ld/testsuite/ld-plugin/plugin-6.d
index b1854ac0..aef588f0 100644
--- a/ld/testsuite/ld-plugin/plugin-6.d
+++ b/ld/testsuite/ld-plugin/plugin-6.d
@@ -29,5 +29,6 @@ hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 hook called: all symbols read.
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
 #...
diff --git a/ld/testsuite/ld-plugin/plugin-7.d b/ld/testsuite/ld-plugin/plugin-7.d
index c77b66fa..a2f41d19 100644
--- a/ld/testsuite/ld-plugin/plugin-7.d
+++ b/ld/testsuite/ld-plugin/plugin-7.d
@@ -30,5 +30,6 @@ hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 hook called: all symbols read.
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
 #...
diff --git a/ld/testsuite/ld-plugin/plugin-8.d b/ld/testsuite/ld-plugin/plugin-8.d
index ca24227a..e26c1050 100644
--- a/ld/testsuite/ld-plugin/plugin-8.d
+++ b/ld/testsuite/ld-plugin/plugin-8.d
@@ -34,5 +34,6 @@ Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 .*: tmpdir/main.o: in function `main':
 .*main.c.*: undefined reference to `\.?func'
+.*main.c.*: undefined reference to `\.?func'
 hook called: cleanup.
 #...
diff --git a/ld/testsuite/ld-scripts/fill.d b/ld/testsuite/ld-scripts/fill.d
index cfe1e524..0e2ad2fe 100644
--- a/ld/testsuite/ld-scripts/fill.d
+++ b/ld/testsuite/ld-scripts/fill.d
@@ -7,7 +7,7 @@
 #skip: ia64-*-* mips*-*-freebsd* mips*-*-gnu* mips*-*-irix* mips*-*-kfreebsd*
 #skip: mips*-*-linux* mips*-*-netbsd* mips*-*-openbsd* mips*-*-sysv4* sh-*-pe
 #skip: tilegx*-*-* tilepro-*-* x86_64-*-cygwin x86_64-*-mingw* x86_64-*-pe*
-#xfail: alpha*-*-*ecoff sparc*-*-coff
+#xfail: alpha*-*-*ecoff sw_64*-*-*ecoff sparc*-*-coff
 #xfail: tic30-*-coff tic4x-*-* tic54x-*-* z8k-*-*
 #
 # See also fill16.d.  We use `skip' for configurations unsupported
@@ -16,6 +16,7 @@
 # configurations are listed above.
 #
 # alpha-linuxecoff pads out code to 16 bytes.
+# sw_64-linuxecoff pads out code to 16 bytes.
 # ia64 aligns code to minimum 16 bytes.
 # mips aligns to minimum 16 bytes (except for bare-metal ELF and VxWorks).
 # sh-pe pads out code sections to 16 bytes
diff --git a/ld/testsuite/ld-scripts/fill16.d b/ld/testsuite/ld-scripts/fill16.d
index e5819df7..86ea9003 100644
--- a/ld/testsuite/ld-scripts/fill16.d
+++ b/ld/testsuite/ld-scripts/fill16.d
@@ -5,7 +5,7 @@
 #objdump: -s -j .text
 #notarget: [is_aout_format]
 #skip: arm-*-coff i[3-7]86-*-coff [is_xcoff_format]
-#xfail: alpha*-*-*ecoff sparc*-*-coff
+#xfail: alpha*-*-*ecoff sw_64*-*-*ecoff sparc*-*-coff
 #xfail: tic30-*-coff tic4x-*-* tic54x-*-* z8k-*-*
 #xfail: z80-*-coff
 #
@@ -15,6 +15,7 @@
 # configurations are listed above.
 #
 # alpha-linuxecoff pads out code to 16 bytes.
+# sw_64-linuxecoff pads out code to 16 bytes.
 # arm-coff always aligns code to 4 bytes.
 # i386-coff always aligns code to 4 bytes.
 # sh-pe pads out code sections to 16 bytes
diff --git a/ld/testsuite/ld-scripts/pr27100.d b/ld/testsuite/ld-scripts/pr27100.d
index 28b5875d..d516ca3b 100644
--- a/ld/testsuite/ld-scripts/pr27100.d
+++ b/ld/testsuite/ld-scripts/pr27100.d
@@ -1,7 +1,7 @@
 #ld: -r -T pr27100.t
 #objdump: -h
 #notarget: [is_aout_format]
-#xfail: alpha*-*-*vms* mmix-*-* *c54x-*-* [is_xcoff_format]
+#xfail: alpha*-*-*vms* sw_64*-*-*vms* mmix-*-* *c54x-*-* [is_xcoff_format]
 
 #...
 .* \.data +0+60 .*
diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp
index 0e45f5c0..ff1b87bb 100644
--- a/ld/testsuite/ld-shared/shared.exp
+++ b/ld/testsuite/ld-shared/shared.exp
@@ -53,6 +53,7 @@ if { ![istarget hppa*64*-*-hpux*] \
      && ![istarget sparc*-*-linux*] \
      && ![istarget arm*-*-linux*] \
      && ![istarget alpha*-*-linux*] \
+     && ![istarget sw_64*-*-linux*] \
      && ![istarget rs6000*-*-aix*] \
      && ![istarget powerpc*-*-aix*] \
      && ![istarget s390*-*-linux*] \
@@ -233,6 +234,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
 	setup_xfail "*-*-solaris2*"
 	setup_xfail "ia64-*-linux*"
 	setup_xfail "alpha*-*-linux*"
+        setup_xfail "sw_64*-*-linux*"
 	setup_xfail "powerpc64*-*-*"
 	if { ![istarget hppa*64*-*-linux*] } {
 	    setup_xfail "hppa*-*-linux*"
@@ -259,6 +261,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
 	setup_xfail "powerpc*-*-linux*"
 	setup_xfail "ia64-*-linux*"
 	setup_xfail "alpha*-*-linux*"
+        setup_xfail "sw_64*-*-linux*"
 	setup_xfail "mips*-*-linux*"
 	if { ![istarget hppa*64*-*-linux*] } {
 	    setup_xfail "hppa*-*-linux*"
@@ -314,6 +317,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/m
 	    setup_xfail "*-*-solaris2*"
 	    setup_xfail "ia64-*-linux*"
 	    setup_xfail "alpha*-*-linux*"
+            setup_xfail "sw_64*-*-linux*"
 	    setup_xfail "powerpc64*-*-*"
 	    if { ![istarget hppa*64*-*-linux*] } {
 		setup_xfail "hppa*-*-linux*"
diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
index c8d561b8..54953de9 100644
--- a/ld/testsuite/ld-srec/srec.exp
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -408,6 +408,9 @@ setup_xfail "v850*-*-elf"
 # The S-record linker doesn't handle Alpha Elf relaxation.
 setup_xfail "alpha*-*-elf*" "alpha*-*-linux-*" "alpha*-*-gnu*"
 setup_xfail "alpha*-*-netbsd*"
+#setup_xfail "sw_64*-*-*"
+setup_xfail "sw_64*-*-elf*" "sw_64*-*-linux-*" "sw_64*-*-gnu*"
+setup_xfail "sw_64*-*-netbsd*"
 
 # The S-record linker hasn't any hope of coping with HPPA relocs.
 # Or MeP complex relocs.
@@ -471,6 +474,9 @@ setup_xfail "arm*-*-*"
 setup_xfail "v850*-*-elf"
 setup_xfail "alpha*-*-elf*" "alpha*-*-linux-*" "alpha*-*-gnu*"
 setup_xfail "alpha*-*-netbsd*"
+#setup_xfail "sw_64*-*-*"
+setup_xfail "sw_64*-*-elf*" "sw_64*-*-linux-*" "sw_64*-*-gnu*"
+setup_xfail "sw_64*-*-netbsd*"
 setup_xfail "hppa*-*-*" "mep-*-*"
 setup_xfail "ia64-*-*"
 setup_xfail "*-*-cygwin*" "*-*-mingw*" "*-*-pe*" "*-*-winnt*"
diff --git a/makefile.vms b/makefile.vms
index a9e36340..2b921703 100644
--- a/makefile.vms
+++ b/makefile.vms
@@ -15,6 +15,14 @@ CC = cc
 GASCC = gcc
 endif
 
+ifeq ($(ARCH),SW_64)
+CC = gcc
+GASCC = $(CC)
+else
+CC = cc
+GASCC = gcc
+endif
+
 ifeq ($(CC),cc)
   CHECK-COMPILER = check_compiler
 else
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index b468c0a0..53c6160c 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -97,6 +97,8 @@ TARGET_LIBOPCODES_CFILES = \
 	aarch64-opc-2.c \
 	alpha-dis.c \
 	alpha-opc.c \
+	sw_64-dis.c \
+	sw_64-opc.c \
 	arc-dis.c \
 	arc-ext.c \
 	arc-opc.c \
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
index 3954fdd6..ece36424 100644
--- a/opcodes/Makefile.in
+++ b/opcodes/Makefile.in
@@ -488,6 +488,8 @@ TARGET_LIBOPCODES_CFILES = \
 	aarch64-opc-2.c \
 	alpha-dis.c \
 	alpha-opc.c \
+	sw_64-dis.c \
+	sw_64-opc.c \
 	arc-dis.c \
 	arc-ext.c \
 	arc-opc.c \
@@ -903,6 +905,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64-opc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha-dis.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha-opc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sw_64-opc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sw_64-dis.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc-dis.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc-ext.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc-opc.Plo@am__quote@
diff --git a/opcodes/config.in b/opcodes/config.in
index 392cda5d..59e1358a 100644
--- a/opcodes/config.in
+++ b/opcodes/config.in
@@ -117,3 +117,5 @@
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+#undef TARGET_SW_64
diff --git a/opcodes/configure b/opcodes/configure
index 6ca33dd5..b77fefc1 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -12235,6 +12235,13 @@ if test x${all_targets} = xfalse ; then
 	case "$arch" in
 	bfd_aarch64_arch)	ta="$ta aarch64-asm.lo aarch64-dis.lo aarch64-opc.lo aarch64-asm-2.lo aarch64-dis-2.lo aarch64-opc-2.lo" ;;
 	bfd_alpha_arch)		ta="$ta alpha-dis.lo alpha-opc.lo" ;;
+# ifdef TARGET_SW_64
+  	bfd_sw_64_arch)         ta="$ta sw_64-dis.lo sw_64-opc.lo"
+cat >>confdefs.h <<_ACEOF
+#define TARGET_SW_64
+_ACEOF
+# endif
+        ;;
 	bfd_arc_arch)		ta="$ta arc-dis.lo arc-opc.lo arc-ext.lo" ;;
 	bfd_arm_arch)		ta="$ta arm-dis.lo" ;;
 	bfd_avr_arch)		ta="$ta avr-dis.lo" ;;
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index e564f067..7fd0b600 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -272,6 +272,7 @@ if test x${all_targets} = xfalse ; then
 	case "$arch" in
 	bfd_aarch64_arch)	ta="$ta aarch64-asm.lo aarch64-dis.lo aarch64-opc.lo aarch64-asm-2.lo aarch64-dis-2.lo aarch64-opc-2.lo" ;;
 	bfd_alpha_arch)		ta="$ta alpha-dis.lo alpha-opc.lo" ;;
+	bfd_sw_64_arch)         ta="$ta sw_64-dis.lo sw_64-opc.lo" ;;
 	bfd_arc_arch)		ta="$ta arc-dis.lo arc-opc.lo arc-ext.lo" ;;
 	bfd_arm_arch)		ta="$ta arm-dis.lo" ;;
 	bfd_avr_arch)		ta="$ta avr-dis.lo" ;;
diff --git a/opcodes/configure.com b/opcodes/configure.com
index 2e9ece71..5884c55c 100644
--- a/opcodes/configure.com
+++ b/opcodes/configure.com
@@ -44,6 +44,14 @@ $ FILES="alpha-dis,alpha-opc"
 $ DEFS="""ARCH_alpha"""
 $EOD
 $ endif
+$ if arch.eqs."sw_64"
+$ then
+$   create build.com
+$DECK
+$ FILES="sw_64-dis,sw_64-opc"
+$ DEFS="""ARCH_sw_64"""
+$EOD
+$ endif
 $!
 $ append sys$input build.com
 $DECK
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
index 8590e945..8b416264 100644
--- a/opcodes/disassemble.c
+++ b/opcodes/disassemble.c
@@ -26,6 +26,9 @@
 #ifdef ARCH_all
 #define ARCH_aarch64
 #define ARCH_alpha
+#ifdef TARGET_SW_64
+#define ARCH_sw_64
+#endif
 #define ARCH_arc
 #define ARCH_arm
 #define ARCH_avr
@@ -145,6 +148,13 @@ disassembler (enum bfd_architecture a,
       disassemble = print_insn_alpha;
       break;
 #endif
+#ifdef TARGET_SW_64
+#ifdef ARCH_sw_64
+    case bfd_arch_sw_64:
+      disassemble = print_insn_sw_64;
+      break;
+#endif
+#endif
 #ifdef ARCH_arc
     case bfd_arch_arc:
       disassemble = arc_get_disassembler (abfd);
diff --git a/opcodes/disassemble.h b/opcodes/disassemble.h
index 8ee54dc9..77028c3b 100644
--- a/opcodes/disassemble.h
+++ b/opcodes/disassemble.h
@@ -23,6 +23,9 @@
 
 extern int print_insn_aarch64		(bfd_vma, disassemble_info *);
 extern int print_insn_alpha		(bfd_vma, disassemble_info *);
+#ifdef TARGET_SW_64
+extern int print_insn_sw_64             (bfd_vma, disassemble_info *);
+#endif
 extern int print_insn_avr		(bfd_vma, disassemble_info *);
 extern int print_insn_bfin		(bfd_vma, disassemble_info *);
 extern int print_insn_big_arm		(bfd_vma, disassemble_info *);
-- 
2.33.0

