This patch support ZTSO extension. It will turn on the tso flag for elf_flags
once we have enabled Ztso extension.  This is intended to implement v0.1 of
the proposed specification which can be found in Chapter 25 of,
https://github.com/riscv/riscv-isa-manual/releases/download/draft-
20220723-
10eea63/riscv-spec.pdf.
bfd\ChangeLog:
        * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Set TSO flag.
        * elfxx-riscv.c: Add Ztso's arch.
binutils\ChangeLog:
        * readelf.c (get_machine_flags): Set TSO flag.
gas\ChangeLog:
        * config/tc-riscv.c (riscv_set_tso): Ditto.
        (riscv_set_arch): Ditto.
        * testsuite/gas/riscv/ztso.d: New test.
include\ChangeLog:
        * elf/riscv.h (EF_RISCV_TSO): Ditto.
 
   /* Allow linking RVC and non-RVC, and keep the RVC flag.  */
   elf_elfheader (obfd)->e_flags |= new_flags & EF_RISCV_RVC;
 
+  /* Allow linking TSO and non-TSO, and keep the TSO flag.  */
+  elf_elfheader (obfd)->e_flags |= new_flags & EF_RISCV_TSO;
+
   return true;
 
  fail:
 
   {"zvl16384b",                ISA_SPEC_CLASS_DRAFT,           1, 0,  0 },
   {"zvl32768b",                ISA_SPEC_CLASS_DRAFT,           1, 0,  0 },
   {"zvl65536b",                ISA_SPEC_CLASS_DRAFT,           1, 0,  0 },
+  {"ztso",             ISA_SPEC_CLASS_DRAFT,           0, 1,  0 },
   {NULL, 0, 0, 0, 0}
 };
 
 
          if (e_flags & EF_RISCV_RVE)
            strcat (buf, ", RVE");
 
+         if (e_flags & EF_RISCV_TSO)
+           strcat (buf, ", TSO");
+
          switch (e_flags & EF_RISCV_FLOAT_ABI)
            {
            case EF_RISCV_FLOAT_ABI_SOFT:
 
   riscv_opts.rvc = rvc_value;
 }
 
+/* Turn on the tso flag for elf_flags once we have enabled ztso extension.  */
+
+static void
+riscv_set_tso ()
+{
+  elf_flags |= EF_RISCV_TSO;
+}
+
 /* This linked list records all enabled extensions, which are parsed from
    the architecture string.  The architecture string can be set by the
    -march option, the elf architecture attributes, and the --with-arch
   riscv_set_rvc (false);
   if (riscv_subset_supports (&riscv_rps_as, "c"))
     riscv_set_rvc (true);
+
+  if (riscv_subset_supports (&riscv_rps_as, "ztso"))
+    riscv_set_tso ();
 }
 
 /* Indicate -mabi option is explictly set.  */
 
--- /dev/null
+#as: -march=rv64i_ztso
+#readelf: -h
+#source: empty.s
+
+ELF Header:
+#...
+[      ]+Flags:[       ]+0x10, TSO.*
+#...
\ No newline at end of file
 
 /* RISC-V specific values for st_other.  */
 #define STO_RISCV_VARIANT_CC 0x80
 
+/* File uses the TSO model. */
+#define EF_RISCV_TSO 0x0010
+
 /* Additional section types.  */
 #define SHT_RISCV_ATTRIBUTES 0x70000003 /* Section holds attributes.  */