riscv64 binutils 'support'
authordrahn <drahn@openbsd.org>
Wed, 5 May 2021 04:52:39 +0000 (04:52 +0000)
committerdrahn <drahn@openbsd.org>
Wed, 5 May 2021 04:52:39 +0000 (04:52 +0000)
Enable just enough of binutils to be a functional compilation system
with llvm doing the heavy lifting.
With corrections suggested by reviewers.
ok jsg@ kettenis@

15 files changed:
gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper
gnu/usr.bin/binutils-2.17/bfd/Makefile.am
gnu/usr.bin/binutils-2.17/bfd/Makefile.in
gnu/usr.bin/binutils-2.17/bfd/archures.c
gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h
gnu/usr.bin/binutils-2.17/bfd/config.bfd
gnu/usr.bin/binutils-2.17/bfd/configure
gnu/usr.bin/binutils-2.17/bfd/cpu-riscv64.c [new file with mode: 0644]
gnu/usr.bin/binutils-2.17/bfd/elf64-riscv.c [new file with mode: 0644]
gnu/usr.bin/binutils-2.17/bfd/targets.c
gnu/usr.bin/binutils-2.17/configure
gnu/usr.bin/binutils-2.17/configure.in
gnu/usr.bin/binutils-2.17/gas/bfin-lex.c
gnu/usr.bin/binutils-2.17/opcodes/configure
gnu/usr.bin/binutils-2.17/opcodes/configure.in

index 41ca6e5..f7c2af0 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile.bsd-wrapper,v 1.21 2020/05/30 19:22:00 drahn Exp $
+#      $OpenBSD: Makefile.bsd-wrapper,v 1.22 2021/05/05 04:52:39 drahn Exp $
 
 .include <bsd.own.mk>
 
@@ -32,10 +32,11 @@ INST_SUBDIRS+=      binutils
 MAN+=          binutils/doc/ar.1 binutils/doc/ranlib.1 \
                binutils/doc/strings.1 binutils/doc/strip.1
 
-.if (${TARGET_ARCH} != "aarch64" && ${TARGET_ARCH} != "powerpc64")
-SUBDIRS+=      ld gas
-CONF_SUBDIRS+= ld gas
-INST_SUBDIRS+= ld gas
+.if (${TARGET_ARCH} != "aarch64" && ${TARGET_ARCH} != "powerpc64" && \
+    ${TARGET_ARCH} != "riscv64")
+SUBDIRS+=       ld gas
+CONF_SUBDIRS+=  ld gas
+INST_SUBDIRS+=  ld gas
 MAN+=          gas/doc/as.1    ld/ld.bfd.1
 .if ${LINKER_VERSION:L} == "bfd"
 maninstall:
index bddd324..0a603c7 100644 (file)
@@ -550,6 +550,7 @@ BFD64_BACKENDS = \
        elf64-mmix.lo \
        elf64-sh64.lo \
        elf64-ppc.lo \
+       elf64-riscv.lo \
        elf64-s390.lo \
        elf64-sparc.lo \
        elf64.lo \
@@ -574,6 +575,7 @@ BFD64_BACKENDS_CFILES = \
        elf64-mips.c \
        elf64-mmix.c \
        elf64-ppc.c \
+       elf64-riscv.c \
        elf64-s390.c \
        elf64-sh64.c \
        elf64-sparc.c \
@@ -1782,6 +1784,9 @@ elf64-ppc.lo: elf64-ppc.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/ppc64.h \
   $(INCDIR)/elf/reloc-macros.h elf64-ppc.h elf64-target.h
+elf64-riscv.lo: elf64-riscv.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
+  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h elf64-target.h
 elf64-s390.lo: elf64-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/s390.h \
index 3c04ce1..c005fd7 100644 (file)
@@ -791,6 +791,7 @@ BFD64_BACKENDS = \
        elf64-mmix.lo \
        elf64-sh64.lo \
        elf64-ppc.lo \
+       elf64-riscv.lo \
        elf64-s390.lo \
        elf64-sparc.lo \
        elf64.lo \
@@ -816,6 +817,7 @@ BFD64_BACKENDS_CFILES = \
        elf64-mips.c \
        elf64-mmix.c \
        elf64-ppc.c \
+       elf64-riscv.c \
        elf64-s390.c \
        elf64-sh64.c \
        elf64-sparc.c \
@@ -2358,6 +2360,9 @@ elf64-ppc.lo: elf64-ppc.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/ppc64.h \
   $(INCDIR)/elf/reloc-macros.h elf64-ppc.h elf64-target.h
+elf64-riscv.lo: elf64-riscv.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
+  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h elf64-target.h
 elf64-s390.lo: elf64-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/s390.h \
index 64f60ff..ab2d868 100644 (file)
@@ -383,6 +383,7 @@ DESCRIPTION
 .#define bfd_mach_z80full        7 {* All undocumented instructions.  *}
 .#define bfd_mach_r800           11 {* R800: successor with multiplication.  *}
 .  bfd_arch_aarch64,
+.  bfd_arch_riscv64,
 .  bfd_arch_last
 .  };
 */
@@ -467,6 +468,7 @@ extern const bfd_arch_info_type bfd_pj_arch;
 extern const bfd_arch_info_type bfd_powerpc_archs[];
 #define bfd_powerpc_arch bfd_powerpc_archs[0]
 extern const bfd_arch_info_type bfd_rs6000_arch;
+extern const bfd_arch_info_type bfd_riscv64_arch;
 extern const bfd_arch_info_type bfd_s390_arch;
 extern const bfd_arch_info_type bfd_sh_arch;
 extern const bfd_arch_info_type bfd_sparc_arch;
@@ -531,6 +533,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
     &bfd_or32_arch,
     &bfd_pdp11_arch,
     &bfd_powerpc_arch,
+    &bfd_riscv_arch,
     &bfd_rs6000_arch,
     &bfd_s390_arch,
     &bfd_sh_arch,
index d36a8a9..e17a29d 100644 (file)
@@ -1987,6 +1987,7 @@ enum bfd_architecture
 #define bfd_mach_z80full        7 /* All undocumented instructions.  */
 #define bfd_mach_r800           11 /* R800: successor with multiplication.  */
   bfd_arch_aarch64,
+  bfd_arch_riscv64,
   bfd_arch_last
   };
 
index 40e4c3e..fbf223e 100644 (file)
@@ -92,6 +92,7 @@ or32*)                 targ_archs=bfd_or32_arch ;;
 pdp11*)                 targ_archs=bfd_pdp11_arch ;;
 pj*)            targ_archs="bfd_pj_arch bfd_i386_arch";;
 powerpc*)       targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
+riscv64)        targ_archs=bfd_riscv64_arch ;;
 rs6000)                 targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
 s390*)          targ_archs=bfd_s390_arch ;;
 sh*)            targ_archs=bfd_sh_arch ;;
@@ -178,6 +179,9 @@ case "${targ}" in
     targ_defvec=bfd_elf32_ia64_hpux_big_vec
     targ_selvecs="bfd_elf64_ia64_hpux_big_vec"
     ;;
+  riscv64-*-openbsd*)
+    targ_defvec=bfd_elf64_riscv_vec
+    ;;
   sparc64-*-freebsd* | sparc64-*-netbsd* | sparc64-*-openbsd* | sparc64-*-kfreebsd*-gnu)
     targ_defvec=bfd_elf64_sparc_vec
     targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
index ab6f6cd..ea423d3 100755 (executable)
@@ -13192,6 +13192,7 @@ do
     bfd_elf64_mmix_vec)        tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_powerpc_vec)     tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_powerpcle_vec)   tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
+    bfd_elf64_riscv_vec)       tb="$tb elf64-riscv.lo"; target_size=64 ;;
     bfd_elf64_s390_vec)                tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sh64_vec)                tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_sh64l_vec)       tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
diff --git a/gnu/usr.bin/binutils-2.17/bfd/cpu-riscv64.c b/gnu/usr.bin/binutils-2.17/bfd/cpu-riscv64.c
new file mode 100644 (file)
index 0000000..558f9a9
--- /dev/null
@@ -0,0 +1,40 @@
+/* BFD Support for RISCV
+
+   Copyright 2005 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
+   USA.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_riscv64_arch =
+  {
+    64,                /* Bits in a word.  */
+    64,                /* Bits in an address.  */
+    8,                 /* Bits in a byte.  */
+    bfd_arch_riscv64,
+    0,                 /* Only one machine.  */
+    "riscv",           /* Arch name.  */
+    "riscv:rv64",              /* Arch printable name.  */
+    4,                 /* Section align power.  */
+    TRUE,              /* The one and only.  */
+    bfd_default_compatible, 
+    bfd_default_scan ,
+    0,
+  };
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf64-riscv.c b/gnu/usr.bin/binutils-2.17/bfd/elf64-riscv.c
new file mode 100644 (file)
index 0000000..66fb793
--- /dev/null
@@ -0,0 +1,69 @@
+/* Generic support for 64-bit ELF
+   Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* This does not include any relocation information, but should be
+   good enough for GDB or objdump to read the file.  */
+
+static reloc_howto_type dummy =
+  HOWTO (0,                    /* type */
+        0,                     /* rightshift */
+        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        0,                     /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        NULL,                  /* special_function */
+        "UNKNOWN",             /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0,                     /* dst_mask */
+        FALSE);                /* pcrel_offset */
+
+static void
+elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+                          arelent *bfd_reloc,
+                          Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
+{
+  bfd_reloc->howto = &dummy;
+}
+
+static void
+elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
+                              arelent *bfd_reloc,
+                              Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
+{
+  bfd_reloc->howto = &dummy;
+}
+
+#define TARGET_LITTLE_SYM              bfd_elf64_riscv_vec
+#define TARGET_LITTLE_NAME             "elf64-riscv"
+#define ELF_ARCH                       bfd_arch_riscv64
+#define ELF_MACHINE_CODE               EM_RISCV
+#define ELF_MAXPAGESIZE                        0x1000
+#define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+#define elf_info_to_howto              elf_generic_info_to_howto
+#define elf_info_to_howto_rel          elf_generic_info_to_howto_rel
+
+#include "elf64-target.h"
index f814490..7c23d41 100644 (file)
@@ -663,6 +663,7 @@ extern const bfd_target bfd_elf64_littlemips_vec;
 extern const bfd_target bfd_elf64_mmix_vec;
 extern const bfd_target bfd_elf64_powerpc_vec;
 extern const bfd_target bfd_elf64_powerpcle_vec;
+extern const bfd_target bfd_elf64_riscv_vec;
 extern const bfd_target bfd_elf64_s390_vec;
 extern const bfd_target bfd_elf64_sh64_vec;
 extern const bfd_target bfd_elf64_sh64l_vec;
index ba999a3..999d8c2 100755 (executable)
@@ -1237,6 +1237,9 @@ case "${target}" in
        ;;
     esac
     ;;
+  riscv*-*-openbsd*)
+    noconfigdirs="ld gas"
+    ;;
   *-*-netware*)
     noconfigdirs="$noconfigdirs target-newlib target-libiberty target-libgloss ${libgcj} target-libmudflap"
     ;;
@@ -1585,6 +1588,9 @@ case "${target}" in
   mips*-*-*)
     noconfigdirs="$noconfigdirs gprof ${libgcj}"
     ;;
+  riscv*-*-openbsd*)
+    noconfigdirs="ld gas"
+    ;;
   romp-*-*)
     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
     ;;
index 3cf10f0..4e71d49 100644 (file)
@@ -777,6 +777,9 @@ case "${target}" in
   mips*-*-*)
     noconfigdirs="$noconfigdirs gprof ${libgcj}"
     ;;
+  riscv*-*-openbsd*)
+    noconfigdirs="$noconfigdirs gas ld"
+    ;;
   romp-*-*)
     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
     ;;
index 9bbdc67..3992a32 100644 (file)
@@ -1,7 +1,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /home/cvs/src/gnu/usr.bin/binutils-2.17/gas/bfin-lex.c,v 1.1.1.1 2011/04/24 20:14:44 miod Exp $
+ * $Header: /home/cvs/src/gnu/usr.bin/binutils-2.17/gas/bfin-lex.c,v 1.2 2021/05/05 04:52:39 drahn Exp $
  */
 
 #define FLEX_SCANNER
index 7849ffe..1a4e412 100755 (executable)
@@ -8846,6 +8846,7 @@ if test x${all_targets} = xfalse ; then
        bfd_powerpc_arch)       ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_powerpc_64_arch)    ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_pyramid_arch)       ;;
+       bfd_riscv64_arch)       ;;
        bfd_romp_arch)          ;;
        bfd_rs6000_arch)        ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_s390_arch)          ta="$ta s390-dis.lo s390-opc.lo" ;;
index c98802c..7d4617d 100644 (file)
@@ -198,6 +198,7 @@ if test x${all_targets} = xfalse ; then
        bfd_powerpc_arch)       ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_powerpc_64_arch)    ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_pyramid_arch)       ;;
+       bfd_riscv64_arch)       ;;
        bfd_romp_arch)          ;;
        bfd_rs6000_arch)        ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_s390_arch)          ta="$ta s390-dis.lo s390-opc.lo" ;;