riscv: tool chain

issue #1880
This commit is contained in:
Sebastian Sumpf 2015-05-26 15:16:57 +02:00 committed by Josef Söntgen
parent d424134073
commit 8cddd86a4c
9 changed files with 22649 additions and 21 deletions

View File

@ -0,0 +1,633 @@
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 6f64f06..eb01c09 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -931,6 +931,18 @@ elf64-ia64.c : elfnn-ia64.c
sed -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new
mv -f elf64-ia64.new elf64-ia64.c
+elf32-riscv.c : elfnn-riscv.c
+ rm -f elf32-riscv.c
+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf32-riscv.new
+ sed -e s/NN/32/g < $(srcdir)/elfnn-riscv.c >> elf32-riscv.new
+ mv -f elf32-riscv.new elf32-riscv.c
+
+elf64-riscv.c : elfnn-riscv.c
+ rm -f elf64-riscv.c
+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf64-riscv.new
+ sed -e s/NN/64/g < $(srcdir)/elfnn-riscv.c >> elf64-riscv.new
+ mv -f elf64-riscv.new elf64-riscv.c
+
peigen.c : peXXigen.c
rm -f peigen.c
sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 2c385d5..abc26f7 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -442,6 +442,7 @@ ALL_MACHINES = \
cpu-pj.lo \
cpu-plugin.lo \
cpu-powerpc.lo \
+ cpu-riscv.lo \
cpu-rs6000.lo \
cpu-rl78.lo \
cpu-rx.lo \
@@ -526,6 +527,7 @@ ALL_MACHINES_CFILES = \
cpu-pj.c \
cpu-plugin.c \
cpu-powerpc.c \
+ cpu-riscv.c \
cpu-rs6000.c \
cpu-rl78.c \
cpu-rx.c \
@@ -2009,6 +2011,18 @@ elf64-ia64.c : elfnn-ia64.c
sed -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new
mv -f elf64-ia64.new elf64-ia64.c
+elf32-riscv.c : elfnn-riscv.c
+ rm -f elf32-riscv.c
+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf32-riscv.new
+ sed -e s/NN/32/g < $(srcdir)/elfnn-riscv.c >> elf32-riscv.new
+ mv -f elf32-riscv.new elf32-riscv.c
+
+elf64-riscv.c : elfnn-riscv.c
+ rm -f elf64-riscv.c
+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf64-riscv.new
+ sed -e s/NN/64/g < $(srcdir)/elfnn-riscv.c >> elf64-riscv.new
+ mv -f elf64-riscv.new elf64-riscv.c
+
peigen.c : peXXigen.c
rm -f peigen.c
sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new
diff --git a/bfd/archures.c b/bfd/archures.c
index c9fd6c8..8cbc157 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -597,6 +597,7 @@ extern const bfd_arch_info_type bfd_pj_arch;
extern const bfd_arch_info_type bfd_plugin_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_riscv_arch;
extern const bfd_arch_info_type bfd_rs6000_arch;
extern const bfd_arch_info_type bfd_rl78_arch;
extern const bfd_arch_info_type bfd_rx_arch;
@@ -683,6 +684,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
&bfd_or1k_arch,
&bfd_pdp11_arch,
&bfd_powerpc_arch,
+ &bfd_riscv_arch,
&bfd_rs6000_arch,
&bfd_rl78_arch,
&bfd_rx_arch,
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index c7a2bb5..9d79d14 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2043,6 +2043,9 @@ enum bfd_architecture
#define bfd_mach_ppc_e6500 5007
#define bfd_mach_ppc_titan 83
#define bfd_mach_ppc_vle 84
+ bfd_arch_riscv, /* RISC-V */
+#define bfd_mach_riscv32 132
+#define bfd_mach_riscv64 164
bfd_arch_rs6000, /* IBM RS/6000 */
#define bfd_mach_rs6k 6000
#define bfd_mach_rs6k_rs1 6001
@@ -5531,6 +5534,43 @@ relative offset from _GLOBAL_OFFSET_TABLE_ */
value in a word. The relocation is relative offset from */
BFD_RELOC_MICROBLAZE_32_GOTOFF,
+/* RISC-V relocations. */
+ BFD_RELOC_RISCV_HI20,
+ BFD_RELOC_RISCV_PCREL_HI20,
+ BFD_RELOC_RISCV_PCREL_LO12_I,
+ BFD_RELOC_RISCV_PCREL_LO12_S,
+ BFD_RELOC_RISCV_LO12_I,
+ BFD_RELOC_RISCV_LO12_S,
+ BFD_RELOC_RISCV_GPREL12_I,
+ BFD_RELOC_RISCV_GPREL12_S,
+ BFD_RELOC_RISCV_TPREL_HI20,
+ BFD_RELOC_RISCV_TPREL_LO12_I,
+ BFD_RELOC_RISCV_TPREL_LO12_S,
+ BFD_RELOC_RISCV_TPREL_ADD,
+ BFD_RELOC_RISCV_CALL,
+ BFD_RELOC_RISCV_CALL_PLT,
+ BFD_RELOC_RISCV_ADD8,
+ BFD_RELOC_RISCV_ADD16,
+ BFD_RELOC_RISCV_ADD32,
+ BFD_RELOC_RISCV_ADD64,
+ BFD_RELOC_RISCV_SUB8,
+ BFD_RELOC_RISCV_SUB16,
+ BFD_RELOC_RISCV_SUB32,
+ BFD_RELOC_RISCV_SUB64,
+ BFD_RELOC_RISCV_GOT_HI20,
+ BFD_RELOC_RISCV_TLS_GOT_HI20,
+ BFD_RELOC_RISCV_TLS_GD_HI20,
+ BFD_RELOC_RISCV_JMP,
+ BFD_RELOC_RISCV_TLS_DTPMOD32,
+ BFD_RELOC_RISCV_TLS_DTPREL32,
+ BFD_RELOC_RISCV_TLS_DTPMOD64,
+ BFD_RELOC_RISCV_TLS_DTPREL64,
+ BFD_RELOC_RISCV_TLS_TPREL32,
+ BFD_RELOC_RISCV_TLS_TPREL64,
+ BFD_RELOC_RISCV_ALIGN,
+ BFD_RELOC_RISCV_RVC_BRANCH,
+ BFD_RELOC_RISCV_RVC_JUMP,
+
/* This is used to tell the dynamic linker to copy the value out of
the dynamic object into the runtime process image. */
BFD_RELOC_MICROBLAZE_COPY,
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 7bcb92a..6f4b053 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -119,6 +119,7 @@ or1k*|or1knd*) targ_archs=bfd_or1k_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" ;;
+riscv*) targ_archs=bfd_riscv_arch ;;
rs6000) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
s390*) targ_archs=bfd_s390_arch ;;
sh*) targ_archs=bfd_sh_arch ;;
@@ -1319,6 +1320,14 @@ case "${targ}" in
targ_defvec=rl78_elf32_vec
;;
+#ifdef BFD64
+ riscv*-*-*)
+ targ_defvec=riscv_elf64_vec
+ targ_selvecs="riscv_elf32_vec riscv_elf64_vec"
+ want64=true
+ ;;
+#endif
+
rx-*-elf)
targ_defvec=rx_elf32_le_vec
targ_selvecs="rx_elf32_be_vec rx_elf32_le_vec rx_elf32_be_ns_vec"
diff --git a/bfd/configure b/bfd/configure
index 7016194..aad4432 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -15506,6 +15506,8 @@ do
powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
powerpc_pei_le_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
powerpc_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
+ riscv_elf32_vec) tb="$tb elf32-riscv.lo elfxx-riscv.lo elf32.lo $elf" ;;
+ riscv_elf64_vec) tb="$tb elf64-riscv.lo elf64.lo elfxx-riscv.lo elf32.lo $elf"; target_size=64 ;;
rl78_elf32_vec) tb="$tb elf32-rl78.lo elf32.lo $elf" ;;
rs6000_xcoff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
rs6000_xcoff64_aix_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
diff --git a/bfd/configure.ac b/bfd/configure.ac
index ba98e39..93ad0d0 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -907,6 +907,8 @@ do
powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
powerpc_pei_le_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
powerpc_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
+ riscv_elf32_vec) tb="$tb elf32-riscv.lo elfxx-riscv.lo elf32.lo $elf" ;;
+ riscv_elf64_vec) tb="$tb elf64-riscv.lo elf64.lo elfxx-riscv.lo elf32.lo $elf"; target_size=64 ;;
rl78_elf32_vec) tb="$tb elf32-rl78.lo elf32.lo $elf" ;;
rs6000_xcoff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
rs6000_xcoff64_aix_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 72e7a66..dc488af 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -433,6 +433,7 @@ enum elf_target_id
XGATE_ELF_DATA,
TILEGX_ELF_DATA,
TILEPRO_ELF_DATA,
+ RISCV_ELF_DATA,
GENERIC_ELF_DATA
};
diff --git a/bfd/targets.c b/bfd/targets.c
index 8323e92..a28c0cf 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -784,6 +784,8 @@ extern const bfd_target powerpc_pe_le_vec;
extern const bfd_target powerpc_pei_vec;
extern const bfd_target powerpc_pei_le_vec;
extern const bfd_target powerpc_xcoff_vec;
+extern const bfd_target riscv_elf32_vec;
+extern const bfd_target riscv_elf64_vec;
extern const bfd_target rl78_elf32_vec;
extern const bfd_target rs6000_xcoff64_vec;
extern const bfd_target rs6000_xcoff64_aix_vec;
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 0c00b2f..e3d7e5c 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -125,6 +125,7 @@
#include "elf/metag.h"
#include "elf/microblaze.h"
#include "elf/mips.h"
+#include "elf/riscv.h"
#include "elf/mmix.h"
#include "elf/mn10200.h"
#include "elf/mn10300.h"
@@ -720,6 +721,7 @@ guess_is_rela (unsigned int e_machine)
case EM_OR1K:
case EM_PPC64:
case EM_PPC:
+ case EM_RISCV:
case EM_RL78:
case EM_RX:
case EM_S390:
@@ -1252,6 +1254,10 @@ dump_relocations (FILE * file,
rtype = elf_mips_reloc_type (type);
break;
+ case EM_RISCV:
+ rtype = elf_riscv_reloc_type (type);
+ break;
+
case EM_ALPHA:
rtype = elf_alpha_reloc_type (type);
break;
@@ -2164,6 +2170,7 @@ get_machine_name (unsigned e_machine)
case EM_CR16:
case EM_MICROBLAZE:
case EM_MICROBLAZE_OLD: return "Xilinx MicroBlaze";
+ case EM_RISCV: return "RISC-V";
case EM_RL78: return "Renesas RL78";
case EM_RX: return "Renesas RX";
case EM_METAG: return "Imagination Technologies Meta processor architecture";
@@ -2951,6 +2958,16 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
decode_NDS32_machine_flags (e_flags, buf, sizeof buf);
break;
+ case EM_RISCV:
+ if (e_flags & EF_RISCV_RVC)
+ strcat (buf, ", RVC");
+
+ if (!EF_GET_RISCV_EXT (e_flags))
+ break;
+ strcat (buf, ", ");
+ strcat (buf, riscv_elf_flag_to_name (EF_GET_RISCV_EXT (e_flags)));
+ break;
+
case EM_SH:
switch ((e_flags & EF_SH_MACH_MASK))
{
@@ -10789,6 +10806,8 @@ is_32bit_abs_reloc (unsigned int reloc_type)
return reloc_type == 1; /* R_PPC64_ADDR32. */
case EM_PPC:
return reloc_type == 1; /* R_PPC_ADDR32. */
+ case EM_RISCV:
+ return reloc_type == 1; /* R_RISCV_32. */
case EM_RL78:
return reloc_type == 1; /* R_RL78_DIR32. */
case EM_RX:
@@ -10924,6 +10943,8 @@ is_64bit_abs_reloc (unsigned int reloc_type)
return reloc_type == 80; /* R_PARISC_DIR64. */
case EM_PPC64:
return reloc_type == 38; /* R_PPC64_ADDR64. */
+ case EM_RISCV:
+ return reloc_type == 2; /* R_RISCV_64. */
case EM_SPARC32PLUS:
case EM_SPARCV9:
case EM_SPARC:
@@ -11072,6 +11093,7 @@ is_none_reloc (unsigned int reloc_type)
case EM_ADAPTEVA_EPIPHANY:
case EM_PPC: /* R_PPC_NONE. */
case EM_PPC64: /* R_PPC64_NONE. */
+ case EM_RISCV: /* R_RISCV_NONE. */
case EM_ARM: /* R_ARM_NONE. */
case EM_IA_64: /* R_IA64_NONE. */
case EM_SH: /* R_SH_NONE. */
diff --git a/config.sub b/config.sub
index 88a0cb4..2d4be2f 100755
--- a/config.sub
+++ b/config.sub
@@ -335,6 +335,9 @@ case $basic_machine in
ms1)
basic_machine=mt-unknown
;;
+ riscv)
+ basic_machine=riscv-ucb
+ ;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
diff --git a/gas/Makefile.am b/gas/Makefile.am
index 55c86b2..03684bd 100644
--- a/gas/Makefile.am
+++ b/gas/Makefile.am
@@ -171,6 +171,7 @@ TARGET_CPU_CFILES = \
config/tc-pdp11.c \
config/tc-pj.c \
config/tc-ppc.c \
+ config/tc-riscv.c \
config/tc-rl78.c \
config/tc-rx.c \
config/tc-s390.c \
@@ -242,6 +243,7 @@ TARGET_CPU_HFILES = \
config/tc-pdp11.h \
config/tc-pj.h \
config/tc-ppc.h \
+ config/tc-riscv.h \
config/tc-rl78.h \
config/tc-rx.h \
config/tc-s390.h \
diff --git a/gas/Makefile.in b/gas/Makefile.in
index 5dc250f..f53808b 100644
--- a/gas/Makefile.in
+++ b/gas/Makefile.in
@@ -440,6 +440,7 @@ TARGET_CPU_CFILES = \
config/tc-pdp11.c \
config/tc-pj.c \
config/tc-ppc.c \
+ config/tc-riscv.c \
config/tc-rl78.c \
config/tc-rx.c \
config/tc-s390.c \
@@ -511,6 +512,7 @@ TARGET_CPU_HFILES = \
config/tc-pdp11.h \
config/tc-pj.h \
config/tc-ppc.h \
+ config/tc-riscv.h \
config/tc-rl78.h \
config/tc-rx.h \
config/tc-s390.h \
@@ -866,6 +868,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-pdp11.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-pj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-ppc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-riscv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-rl78.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-rx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-s390.Po@am__quote@
@@ -1571,6 +1574,20 @@ tc-ppc.obj: config/tc-ppc.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-ppc.obj `if test -f 'config/tc-ppc.c'; then $(CYGPATH_W) 'config/tc-ppc.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-ppc.c'; fi`
+tc-riscv.o: config/tc-riscv.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-riscv.o -MD -MP -MF $(DEPDIR)/tc-riscv.Tpo -c -o tc-riscv.o `test -f 'config/tc-riscv.c' || echo '$(srcdir)/'`config/tc-riscv.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-riscv.Tpo $(DEPDIR)/tc-riscv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-riscv.c' object='tc-riscv.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-riscv.o `test -f 'config/tc-riscv.c' || echo '$(srcdir)/'`config/tc-riscv.c
+
+tc-riscv.obj: config/tc-riscv.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-riscv.obj -MD -MP -MF $(DEPDIR)/tc-riscv.Tpo -c -o tc-riscv.obj `if test -f 'config/tc-riscv.c'; then $(CYGPATH_W) 'config/tc-riscv.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-riscv.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-riscv.Tpo $(DEPDIR)/tc-riscv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-riscv.c' object='tc-riscv.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-riscv.obj `if test -f 'config/tc-riscv.c'; then $(CYGPATH_W) 'config/tc-riscv.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-riscv.c'; fi`
+
tc-rl78.o: config/tc-rl78.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-rl78.o -MD -MP -MF $(DEPDIR)/tc-rl78.Tpo -c -o tc-rl78.o `test -f 'config/tc-rl78.c' || echo '$(srcdir)/'`config/tc-rl78.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-rl78.Tpo $(DEPDIR)/tc-rl78.Po
diff --git a/gas/configure b/gas/configure
index 76b5f20..81e4ba1 100755
--- a/gas/configure
+++ b/gas/configure
@@ -12400,7 +12400,7 @@ $as_echo "#define NDS32_DEFAULT_AUDIO_EXT 1" >>confdefs.h
$as_echo "$enable_audio_ext" >&6; }
;;
- i386 | s390 | sparc)
+ i386 | riscv | s390 | sparc)
if test $this_target = $target ; then
cat >>confdefs.h <<_ACEOF
diff --git a/gas/configure.ac b/gas/configure.ac
index 371f7b3..357a21c 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -453,7 +453,7 @@ changequote([,])dnl
AC_MSG_RESULT($enable_audio_ext)
;;
- i386 | s390 | sparc)
+ i386 | riscv | s390 | sparc)
if test $this_target = $target ; then
AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
fi
diff --git a/gas/configure.tgt b/gas/configure.tgt
index d07d445..6baa15f 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -86,6 +86,8 @@ case ${cpu} in
pj*) cpu_type=pj endian=big ;;
powerpc*le*) cpu_type=ppc endian=little ;;
powerpc*) cpu_type=ppc endian=big ;;
+ riscv32*) cpu_type=riscv endian=little arch=riscv32 ;;
+ riscv*) cpu_type=riscv endian=little arch=riscv64 ;;
rs6000*) cpu_type=ppc ;;
rl78*) cpu_type=rl78 ;;
rx) cpu_type=rx ;;
@@ -384,6 +386,8 @@ case ${generic_target} in
ppc-*-kaos*) fmt=elf ;;
ppc-*-lynxos*) fmt=elf em=lynx ;;
+ riscv*-*-*) fmt=elf endian=little em=linux ;;
+
s390-*-linux-*) fmt=elf em=linux ;;
s390-*-tpf*) fmt=elf ;;
@@ -478,7 +482,7 @@ case ${generic_target} in
esac
case ${cpu_type} in
- aarch64 | alpha | arm | i386 | ia64 | microblaze | mips | ns32k | or1k | or1knd | pdp11 | ppc | sparc | z80 | z8k)
+ aarch64 | alpha | arm | i386 | ia64 | microblaze | mips | ns32k | or1k | or1knd | pdp11 | ppc | riscv | sparc | z80 | z8k)
bfd_gas=yes
;;
esac
diff --git a/include/dis-asm.h b/include/dis-asm.h
index 1b653b5..d53b9b2 100644
--- a/include/dis-asm.h
+++ b/include/dis-asm.h
@@ -254,6 +254,7 @@ extern int print_insn_little_arm (bfd_vma, disassemble_info *);
extern int print_insn_little_mips (bfd_vma, disassemble_info *);
extern int print_insn_little_nios2 (bfd_vma, disassemble_info *);
extern int print_insn_little_powerpc (bfd_vma, disassemble_info *);
+extern int print_insn_riscv (bfd_vma, disassemble_info *);
extern int print_insn_little_score (bfd_vma, disassemble_info *);
extern int print_insn_lm32 (bfd_vma, disassemble_info *);
extern int print_insn_m32c (bfd_vma, disassemble_info *);
@@ -313,6 +314,7 @@ extern void print_aarch64_disassembler_options (FILE *);
extern void print_i386_disassembler_options (FILE *);
extern void print_mips_disassembler_options (FILE *);
extern void print_ppc_disassembler_options (FILE *);
+extern void print_riscv_disassembler_options (FILE *);
extern void print_arm_disassembler_options (FILE *);
extern void parse_arm_disassembler_option (char *);
extern void print_s390_disassembler_options (FILE *);
diff --git a/include/elf/common.h b/include/elf/common.h
index e8ae3ac..ad24500 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -301,6 +301,7 @@
#define EM_INTEL207 207 /* Reserved by Intel */
#define EM_INTEL208 208 /* Reserved by Intel */
#define EM_INTEL209 209 /* Reserved by Intel */
+#define EM_RISCV 243 /* RISC-V */
/* If it is necessary to assign new unofficial EM_* values, please pick large
random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 9575f1f..04664a0 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -258,6 +258,7 @@ ALL_EMULATION_SOURCES = \
eelf32ppcsim.c \
eelf32ppcvxworks.c \
eelf32ppcwindiss.c \
+ eelf32lriscv.c \
eelf32rl78.c \
eelf32rx.c \
eelf32tilegx.c \
@@ -464,6 +465,7 @@ ALL_64_EMULATION_SOURCES = \
eelf64btsmip_fbsd.c \
eelf64hppa.c \
eelf64lppc.c \
+ eelf64lriscv.c \
eelf64ltsmip.c \
eelf64ltsmip_fbsd.c \
eelf64mmix.c \
@@ -1104,6 +1106,11 @@ eelf32lppcsim.c: $(srcdir)/emulparams/elf32lppcsim.sh \
ldemul-list.h \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+eelf32lriscv.c: $(srcdir)/emulparams/elf32lriscv.sh \
+ $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+ $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+ ${GEN_DEPENDS}
+
eelf32lsmip.c: $(srcdir)/emulparams/elf32lsmip.sh \
$(srcdir)/emulparams/elf32lmip.sh $(srcdir)/emulparams/elf32bmip.sh \
$(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \
@@ -1861,6 +1868,12 @@ eelf64lppc.c: $(srcdir)/emulparams/elf64lppc.sh \
ldemul-list.h \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+eelf64lriscv.c: $(srcdir)/emulparams/elf64lriscv.sh \
+ $(srcdir)/emulparams/elf64lriscv-defs.sh \
+ $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+ $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+ ${GEN_DEPENDS}
+
eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \
$(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \
$(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 9f56ca1..4307710 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -546,6 +546,7 @@ ALL_EMULATION_SOURCES = \
eelf32lppclinux.c \
eelf32lppcnto.c \
eelf32lppcsim.c \
+ eelf32lriscv.c \
eelf32m32c.c \
eelf32mb_linux.c \
eelf32mbel_linux.c \
@@ -771,6 +772,7 @@ ALL_64_EMULATION_SOURCES = \
eelf64btsmip_fbsd.c \
eelf64hppa.c \
eelf64lppc.c \
+ eelf64lriscv.c \
eelf64ltsmip.c \
eelf64ltsmip_fbsd.c \
eelf64mmix.c \
@@ -1157,6 +1159,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppclinux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppcnto.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppcsim.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lriscv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lr5900.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lr5900n32.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lsmip.Po@am__quote@
@@ -1211,6 +1214,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip_fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64hppa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip_fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64mmix.Po@am__quote@
@@ -2545,6 +2549,11 @@ eelf32lppcsim.c: $(srcdir)/emulparams/elf32lppcsim.sh \
ldemul-list.h \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+eelf32lriscv.c: $(srcdir)/emulparams/elf32lriscv.sh \
+ $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+ $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+ ${GEN_DEPENDS}
+
eelf32lsmip.c: $(srcdir)/emulparams/elf32lsmip.sh \
$(srcdir)/emulparams/elf32lmip.sh $(srcdir)/emulparams/elf32bmip.sh \
$(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \
@@ -3302,6 +3311,12 @@ eelf64lppc.c: $(srcdir)/emulparams/elf64lppc.sh \
ldemul-list.h \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+eelf64lriscv.c: $(srcdir)/emulparams/elf64lriscv.sh \
+ $(srcdir)/emulparams/elf64lriscv-defs.sh \
+ $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+ $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+ ${GEN_DEPENDS}
+
eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \
$(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \
$(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 24e36d1..11353f3 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -604,6 +604,12 @@ powerpc-*-aix*) targ_emul=aixppc ;;
powerpc-*-beos*) targ_emul=aixppc ;;
powerpc-*-windiss*) targ_emul=elf32ppcwindiss ;;
powerpc-*-lynxos*) targ_emul=ppclynx ;;
+riscv32*-*-*) targ_emul=elf32lriscv
+ targ_extra_emuls="elf64lriscv"
+ targ_extra_libpath=$targ_extra_emuls ;;
+riscv*-*-*) targ_emul=elf64lriscv
+ targ_extra_emuls="elf32lriscv"
+ targ_extra_libpath=$targ_extra_emuls ;;
rs6000-*-aix[5-9]*) targ_emul=aix5rs6 ;;
rs6000-*-aix*) targ_emul=aixrs6
;;
diff --git a/opcodes/configure b/opcodes/configure
index 1361ef6..f8fca0c 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -12590,6 +12590,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_riscv_arch) ta="$ta riscv-dis.lo riscv-opc.lo" ;;
bfd_romp_arch) ;;
bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
bfd_rl78_arch) ta="$ta rl78-dis.lo rl78-decode.lo";;
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
index 0a0814e..1e83180 100644
--- a/opcodes/disassemble.c
+++ b/opcodes/disassemble.c
@@ -373,6 +373,11 @@ disassembler (abfd)
disassemble = print_insn_little_powerpc;
break;
#endif
+#ifdef ARCH_riscv
+ case bfd_arch_riscv:
+ disassemble = print_insn_riscv;
+ break;
+#endif
#ifdef ARCH_rs6000
case bfd_arch_rs6000:
if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
@@ -545,6 +550,9 @@ disassembler_usage (stream)
#ifdef ARCH_powerpc
print_ppc_disassembler_options (stream);
#endif
+#ifdef ARCH_riscv
+ print_riscv_disassembler_options (stream);
+#endif
#ifdef ARCH_i386
print_i386_disassembler_options (stream);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
riscv_files.patch
riscv.patch

View File

@ -1,20 +1,8 @@
config.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
gcc/config.gcc | 4 ++--
gcc/config/arm/unknown-elf.h | 16 ++++++++++++++++
gcc/config/i386/x86-64.h | 19 +++++++++++++++++++
libgcc/config.host | 12 ++++++++++--
4 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9d3fa57..20daf70 100644
index b7ebc07..5acf469 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1056,7 +1056,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
@@ -1060,7 +1060,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
case ${target} in
arm*-*-eabi*)
tm_file="$tm_file newlib-stdint.h"
@ -23,7 +11,16 @@ index 9d3fa57..20daf70 100644
use_gcc_stdint=wrap
;;
arm*-*-rtems*)
@@ -2890,7 +2890,7 @@ i[34567]86-*-linux* | x86_64-*-linux*)
@@ -1969,7 +1969,7 @@ riscv*-*-linux*) # Linux RISC-V
;;
riscv*-*-elf*) # Linux RISC-V
tm_file="elfos.h newlib-stdint.h ${tm_file} riscv/elf.h"
- tmake_file="${tmake_file} riscv/t-elf"
+ tmake_file="${tmake_file} riscv/t-elf t-slibgcc"
gnu_ld=yes
gas=yes
gcc_cv_initfini_array=yes
@@ -2915,7 +2915,7 @@ i[34567]86-*-linux* | x86_64-*-linux*)
tmake_file="${tmake_file} i386/t-pmm_malloc i386/t-i386"
;;
i[34567]86-*-* | x86_64-*-*)
@ -83,11 +80,34 @@ index 16fc685..85b07bb 100644
+/* Don't assume anything about the header files. */
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57699 */
+#define NO_IMPLICIT_EXTERN_C
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 4533cff..1f78497 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -171,14 +171,11 @@ along with GCC; see the file COPYING3. If not see
%(subtarget_asm_spec)"
/* Extra switches sometimes passed to the linker. */
-
-#ifndef LINK_SPEC
+#undef LINK_SPEC
#define LINK_SPEC "\
-%{!T:-dT riscv.ld} \
-%{m64:-melf64lriscv} \
-%{m32:-melf32lriscv} \
-%{shared}"
-#endif /* LINK_SPEC defined */
+-melf64lriscv \
+%{shared:-shared} \
+%{!static:--eh-frame-hdr}"
/* This macro defines names of additional specifications to put in the specs
that can be used in various specifications like CC1_SPEC. Its definition
diff --git a/libgcc/config.host b/libgcc/config.host
index f4a7428..c9bce6a 100644
index 8a30368..83b5dba 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -297,7 +297,7 @@ case ${host} in
@@ -300,7 +300,7 @@ case ${host} in
tmake_file=t-vxworks
;;
*-*-elf)
@ -96,7 +116,7 @@ index f4a7428..c9bce6a 100644
;;
esac
@@ -384,8 +384,12 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
@@ -387,8 +387,12 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
tm_file="$tm_file arm/bpabi-lib.h"
case ${host} in
arm*-*-eabi* | arm*-*-rtems*)
@ -110,7 +130,7 @@ index f4a7428..c9bce6a 100644
;;
arm*-*-symbianelf*)
tmake_file="${tmake_file} arm/t-symbian t-slibgcc-nolc-override"
@@ -543,6 +547,10 @@ i[34567]86-*-elf*)
@@ -546,6 +550,10 @@ i[34567]86-*-elf*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
x86_64-*-elf*)
@ -121,3 +141,14 @@ index f4a7428..c9bce6a 100644
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
i[34567]86-*-freebsd*)
@@ -1014,8 +1022,8 @@ riscv*-*-linux*)
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
;;
riscv*-*-*)
- tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-elf"
- extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
+ tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-elf t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
;;
rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*)
md_unwind_header=rs6000/aix-unwind.h

View File

@ -0,0 +1,463 @@
diff --git a/config.sub b/config.sub
index 61cb4bc..d6e23cb 100755
--- a/config.sub
+++ b/config.sub
@@ -334,6 +334,9 @@ case $basic_machine in
ms1)
basic_machine=mt-unknown
;;
+ riscv)
+ basic_machine=riscv-ucb
+ ;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9d3fa57..b7ebc07 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -447,6 +447,10 @@ powerpc*-*-*)
esac
extra_options="${extra_options} g.opt fused-madd.opt rs6000/rs6000-tables.opt"
;;
+riscv*)
+ cpu_type=riscv
+ need_64bit_hwint=yes
+ ;;
rs6000*-*-*)
need_64bit_hwint=yes
extra_options="${extra_options} g.opt fused-madd.opt rs6000/rs6000-tables.opt"
@@ -1949,6 +1953,27 @@ microblaze*-*-elf)
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
tmake_file="${tmake_file} microblaze/t-microblaze"
;;
+riscv32*-*-linux*) # Linux RISC-V
+ tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h riscv/default-32.h ${tm_file} riscv/linux.h riscv/linux64.h"
+ tmake_file="${tmake_file} riscv/t-linux64"
+ gnu_ld=yes
+ gas=yes
+ gcc_cv_initfini_array=yes
+ ;;
+riscv*-*-linux*) # Linux RISC-V
+ tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} riscv/linux.h riscv/linux64.h"
+ tmake_file="${tmake_file} riscv/t-linux64"
+ gnu_ld=yes
+ gas=yes
+ gcc_cv_initfini_array=yes
+ ;;
+riscv*-*-elf*) # Linux RISC-V
+ tm_file="elfos.h newlib-stdint.h ${tm_file} riscv/elf.h"
+ tmake_file="${tmake_file} riscv/t-elf"
+ gnu_ld=yes
+ gas=yes
+ gcc_cv_initfini_array=yes
+ ;;
mips*-*-netbsd*) # NetBSD/mips, either endian.
target_cpu_default="MASK_ABICALLS"
tm_file="elfos.h ${tm_file} mips/elf.h netbsd.h netbsd-elf.h mips/netbsd.h"
@@ -3756,6 +3781,31 @@ case "${target}" in
done
;;
+ riscv*-*-*)
+ supported_defaults="abi arch arch_32 arch_64 float tune tune_32 tune_64"
+
+ case ${with_float} in
+ "" | soft | hard)
+ # OK
+ ;;
+ *)
+ echo "Unknown floating point type used in --with-float=$with_float" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case ${with_abi} in
+ "" | 32 | 64)
+ # OK
+ ;;
+ *)
+ echo "Unknown ABI used in --with-abi=$with_abi" 1>&2
+ exit 1
+ ;;
+ esac
+
+ ;;
+
mips*-*-*)
supported_defaults="abi arch arch_32 arch_64 float fpu nan tune tune_32 tune_64 divide llsc mips-plt synci"
diff --git a/gcc/configure b/gcc/configure
index 291e463..dae2d8f 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -23515,6 +23515,25 @@ x3: .space 4
tls_first_minor=14
tls_as_opt="-a32 --fatal-warnings"
;;
+ riscv*-*-*)
+ conftest_s='
+ .section .tdata,"awT",@progbits
+x:
+ .word 2
+ .text
+ la.tls.gd a0,x
+ la.tls.ie a1,x
+ lui a0,%tls_ie_pcrel_hi(x)
+ lw a0,%pcrel_lo(x)(a0)
+ add a0,a0,tp
+ lw a0,0(a0)
+ lui a0,%tprel_hi(x)
+ add a0,a0,tp,%tprel_add(x)
+ lw a0,%tprel_lo(x)(a0)'
+ tls_first_major=2
+ tls_first_minor=21
+ tls_as_opt='-m32 --fatal-warnings'
+ ;;
s390-*-*)
conftest_s='
.section ".tdata","awT",@progbits
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b9a3799..c39db9a 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3178,6 +3178,25 @@ x3: .space 4
tls_first_minor=14
tls_as_opt="-a32 --fatal-warnings"
;;
+ riscv*-*-*)
+ conftest_s='
+ .section .tdata,"awT",@progbits
+x:
+ .word 2
+ .text
+ la.tls.gd a0,x
+ la.tls.ie a1,x
+ lui a0,%tls_ie_pcrel_hi(x)
+ lw a0,%pcrel_lo(x)(a0)
+ add a0,a0,tp
+ lw a0,0(a0)
+ lui a0,%tprel_hi(x)
+ add a0,a0,tp,%tprel_add(x)
+ lw a0,%tprel_lo(x)(a0)'
+ tls_first_major=2
+ tls_first_minor=21
+ tls_as_opt='-m32 --fatal-warnings'
+ ;;
s390-*-*)
conftest_s='
.section ".tdata","awT",@progbits
diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index 1952dbd..7015082 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -6,6 +6,9 @@
#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)
/* On PPC division by zero does not trap. */
# define DO_TEST 0
+#elif defined (__riscv__)
+ /* On RISC-V division by zero does not trap. */
+# define DO_TEST 0
#elif defined (__SPU__)
/* On SPU division by zero does not trap. */
# define DO_TEST 0
diff --git a/gcc/testsuite/gcc.dg/20020312-2.c b/gcc/testsuite/gcc.dg/20020312-2.c
index 63fbfcc..b346eba 100644
--- a/gcc/testsuite/gcc.dg/20020312-2.c
+++ b/gcc/testsuite/gcc.dg/20020312-2.c
@@ -66,6 +66,8 @@ extern void abort (void);
# else
# define PIC_REG "30"
# endif
+#elif defined(__riscv__)
+/* No pic register. */
#elif defined(__RX__)
/* No pic register. */
#elif defined(__s390__)
diff --git a/gcc/testsuite/gcc.dg/20040813-1.c b/gcc/testsuite/gcc.dg/20040813-1.c
index 8be831d..bc74ec8 100644
--- a/gcc/testsuite/gcc.dg/20040813-1.c
+++ b/gcc/testsuite/gcc.dg/20040813-1.c
@@ -2,7 +2,7 @@
/* Contributed by Devang Patel <dpatel@apple.com> */
/* { dg-do compile } */
-/* { dg-skip-if "No stabs" { aarch64*-*-* mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* tile*-*-* nios2-*-* *-*-vxworks* } { "*" } { "" } } */
+/* { dg-skip-if "No stabs" { aarch64*-*-* mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* riscv*-*-* tile*-*-* nios2-*-* *-*-vxworks* } { "*" } { "" } } */
/* { dg-options "-gstabs" } */
int
diff --git a/gcc/testsuite/gcc.dg/stack-usage-1.c b/gcc/testsuite/gcc.dg/stack-usage-1.c
index 05e3df7..4afc483 100644
--- a/gcc/testsuite/gcc.dg/stack-usage-1.c
+++ b/gcc/testsuite/gcc.dg/stack-usage-1.c
@@ -61,6 +61,8 @@
# else
# define SIZE 240
# endif
+#elif defined (__riscv__)
+# define SIZE 240
#elif defined (__AVR__)
# define SIZE 254
#elif defined (__s390x__)
diff --git a/libatomic/cas_n.c b/libatomic/cas_n.c
index 801262d..a885afa 100644
--- a/libatomic/cas_n.c
+++ b/libatomic/cas_n.c
@@ -70,7 +70,7 @@ SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
mask = -1;
}
- weval = *eptr << shift;
+ weval = (UWORD)*eptr << shift;
wnewval = (UWORD)newval << shift;
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
do
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index a3757ef..516348d 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -29,6 +29,7 @@
case "${target_cpu}" in
alpha*) ARCH=alpha ;;
rs6000 | powerpc*) ARCH=powerpc ;;
+ riscv*) ARCH=riscv ;;
sh*) ARCH=sh ;;
arm*)
diff --git a/libatomic/fop_n.c b/libatomic/fop_n.c
index 4a18da9..854d648 100644
--- a/libatomic/fop_n.c
+++ b/libatomic/fop_n.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2014 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU Atomic Library (libatomic).
@@ -112,9 +112,9 @@ SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel)
pre_barrier (smodel);
- wptr = (UWORD *)mptr;
- shift = 0;
- mask = -1;
+ wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
+ shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
+ mask = SIZE(MASK) << shift;
wopval = (UWORD)opval << shift;
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
@@ -136,9 +136,9 @@ SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
pre_barrier (smodel);
- wptr = (UWORD *)mptr;
- shift = 0;
- mask = -1;
+ wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
+ shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
+ mask = SIZE(MASK) << shift;
wopval = (UWORD)opval << shift;
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
diff --git a/libcpp/configure b/libcpp/configure
index b421e48..1270509 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7163,6 +7163,7 @@ case $target in
mips*-*-* | \
mmix-*-* | \
powerpc*-*-* | \
+ riscv*-*-* | \
rs6000*-*-* | \
s390*-*-* | \
sparc*-*-* | \
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 8515abf..89df04d 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -192,6 +192,7 @@ case $target in
mips*-*-* | \
mmix-*-* | \
powerpc*-*-* | \
+ riscv*-*-* | \
rs6000*-*-* | \
s390*-*-* | \
sparc*-*-* | \
diff --git a/libgcc/config.host b/libgcc/config.host
index f4a7428..e1f49c8 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -167,6 +167,9 @@ powerpc*-*-*)
;;
rs6000*-*-*)
;;
+riscv*)
+ cpu_type=riscv
+ ;;
score*-*-*)
cpu_type=score
;;
@@ -1002,6 +1005,18 @@ powerpcle-*-eabi*)
tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
;;
+riscv32*-*-linux*)
+ tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-tpbit riscv/t-elf riscv/t-elf32"
+ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
+ ;;
+riscv*-*-linux*)
+ tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-tpbit riscv/t-elf"
+ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
+ ;;
+riscv*-*-*)
+ tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-elf"
+ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
+ ;;
rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*)
md_unwind_header=rs6000/aix-unwind.h
tmake_file="t-fdpbit rs6000/t-ppc64-fp rs6000/t-slibgcc-aix rs6000/t-ibm-ldouble"
diff --git a/libsanitizer/asan/asan_linux.cc b/libsanitizer/asan/asan_linux.cc
index 0692eb1..2a7b656 100644
--- a/libsanitizer/asan/asan_linux.cc
+++ b/libsanitizer/asan/asan_linux.cc
@@ -98,6 +98,11 @@ void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
*pc = ucontext->uc_mcontext.gregs[31];
*bp = ucontext->uc_mcontext.gregs[30];
*sp = ucontext->uc_mcontext.gregs[29];
+# elif defined(__riscv__)
+ ucontext_t *ucontext = (ucontext_t*)context;
+ *pc = ucontext->uc_mcontext.gregs[REG_PC];
+ *bp = ucontext->uc_mcontext.gregs[REG_S0];
+ *sp = ucontext->uc_mcontext.gregs[REG_SP];
#else
# error "Unsupported arch"
#endif
diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc
index 69c9c10..2419ae6 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc
@@ -93,11 +93,11 @@ uptr internal_close(fd_t fd) {
}
uptr internal_open(const char *filename, int flags) {
- return internal_syscall(__NR_open, (uptr)filename, flags);
+ return internal_syscall(__NR_openat, AT_FDCWD, (uptr)filename, flags);
}
uptr internal_open(const char *filename, int flags, u32 mode) {
- return internal_syscall(__NR_open, (uptr)filename, flags, mode);
+ return internal_syscall(__NR_openat, AT_FDCWD, (uptr)filename, flags, mode);
}
uptr OpenFile(const char *filename, bool write) {
@@ -139,7 +139,7 @@ static void stat64_to_stat(struct stat64 *in, struct stat *out) {
uptr internal_stat(const char *path, void *buf) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
- return internal_syscall(__NR_stat, (uptr)path, (uptr)buf);
+ return internal_syscall(__NR_newfstatat, AT_FDCWD, (uptr)path, (uptr)buf, 0);
#else
struct stat64 buf64;
int res = internal_syscall(__NR_stat64, path, &buf64);
@@ -150,7 +150,7 @@ uptr internal_stat(const char *path, void *buf) {
uptr internal_lstat(const char *path, void *buf) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
- return internal_syscall(__NR_lstat, (uptr)path, (uptr)buf);
+ return internal_syscall(__NR_newfstatat, AT_FDCWD, (uptr)path, (uptr)buf, AT_SYMLINK_NOFOLLOW);
#else
struct stat64 buf64;
int res = internal_syscall(__NR_lstat64, path, &buf64);
@@ -178,15 +178,15 @@ uptr internal_filesize(fd_t fd) {
}
uptr internal_dup2(int oldfd, int newfd) {
- return internal_syscall(__NR_dup2, oldfd, newfd);
+ return internal_syscall(__NR_dup3, oldfd, newfd, 0);
}
uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
- return internal_syscall(__NR_readlink, (uptr)path, (uptr)buf, bufsize);
+ return internal_syscall(__NR_readlinkat, AT_FDCWD, (uptr)path, (uptr)buf, bufsize);
}
uptr internal_unlink(const char *path) {
- return internal_syscall(__NR_unlink, (uptr)path);
+ return internal_syscall(__NR_unlinkat, AT_FDCWD, (uptr)path);
}
uptr internal_sched_yield() {
@@ -588,7 +588,7 @@ uptr internal_getppid() {
}
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
- return internal_syscall(__NR_getdents, fd, (uptr)dirp, count);
+ return internal_syscall(__NR_getdents64, fd, (uptr)dirp, count);
}
uptr internal_lseek(fd_t fd, OFF_T offset, int whence) {
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
index ac56f33..8e1ec46 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
@@ -63,7 +63,7 @@ namespace __sanitizer {
unsigned struct_statfs64_sz = sizeof(struct statfs64);
} // namespace __sanitizer
-#if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__sparc__)
+#if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__sparc__) && !defined(__riscv__)
COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
#endif
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
index aec9504..c063107 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -67,6 +67,10 @@ namespace __sanitizer {
const unsigned struct___old_kernel_stat_sz = 0;
const unsigned struct_kernel_stat_sz = 144;
const unsigned struct_kernel_stat64_sz = 104;
+#elif defined(__riscv__)
+ const unsigned struct___old_kernel_stat_sz = 0;
+ const unsigned struct_kernel_stat_sz = 128;
+ const unsigned struct_kernel_stat64_sz = 128;
#elif defined(__sparc__) && defined(__arch64__)
const unsigned struct___old_kernel_stat_sz = 0;
const unsigned struct_kernel_stat_sz = 104;
@@ -367,7 +371,7 @@ namespace __sanitizer {
typedef long __sanitizer___kernel_off_t;
#endif
-#if defined(__powerpc__)
+#if defined(__powerpc__) || defined(__riscv__)
typedef unsigned int __sanitizer___kernel_old_uid_t;
typedef unsigned int __sanitizer___kernel_old_gid_t;
#else
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 16e09f0..acd62fc 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -16550,7 +16550,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# Long term, -std=c++0x could be even better, could manage to explicitly
# request C99 facilities to the underlying C headers.
ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS -std=c++98"
+ CXXFLAGS="$CXXFLAGS -std=gnu++98"
ac_save_LIBS="$LIBS"
ac_save_gcc_no_link="$gcc_no_link"
@@ -17170,9 +17170,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
$as_echo "$glibcxx_cv_c99_wchar" >&6; }
fi
+ # For newlib, don't check complex since missing c99 functions, but
+ # rest of c99 stuff is there so don't loose it
# Option parsed, now set things appropriately.
if test x"$glibcxx_cv_c99_math" = x"no" ||
- test x"$glibcxx_cv_c99_complex" = x"no" ||
+ # test x"$glibcxx_cv_c99_complex" = x"no" ||
test x"$glibcxx_cv_c99_stdio" = x"no" ||
test x"$glibcxx_cv_c99_stdlib" = x"no" ||
test x"$glibcxx_cv_c99_wchar" = x"no"; then

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
riscv_files.patch
riscv.patch
config.patch
misc.patch
no_short_enums.patch

View File

@ -15,6 +15,7 @@ help:
$(ECHO) "--- available commands ---"
$(ECHO) "x86 - create tool chain for x86"
$(ECHO) "arm - create tool chain for arm"
$(ECHO) "riscv - create tool chain for riscv"
$(ECHO) "clean - clean everything except downloaded archives"
$(ECHO) "cleanall - clean everything including downloaded archives"
$(ECHO)
@ -23,7 +24,7 @@ help:
# User interface
#
SUPPORTED_PLATFORMS := x86 arm
SUPPORTED_PLATFORMS := x86 arm riscv
PLATFORM := $(firstword $(filter $(SUPPORTED_PLATFORMS),$(MAKECMDGOALS)))
@ -188,6 +189,7 @@ LOCAL_LIB_INSTALL_LOCATION = $(shell pwd)/build/lib-install
TARGET_NAME_x86 = x86_64-pc-elf
TARGET_NAME_arm = arm-none-eabi
TARGET_NAME_riscv = riscv-unknown-elf
ifneq ($(VERBOSE),)
CONFIG_QUIET = --quiet
@ -276,7 +278,12 @@ BINUTILS_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-o
GCC_BINARIES = build/$(PLATFORM)/gcc/gcc/g++
GCC_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-g++
GDB_BINARIES = build/$(PLATFORM)/gdb/gdb/gdb
ifeq ($(PLATFORM),riscv)
GDB_INSTALLED_BINARIES =
else
GDB_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-gdb
endif
build_all: $(GCC_INSTALLED_BINARIES) $(GDB_INSTALLED_BINARIES)
@ -334,11 +341,13 @@ $(CONTRIB_DIR)/gcc-$(GCC_VERSION): $(addprefix $(DOWNLOAD_DIR)/,gcc-$(GCC_VERSIO
include $(GENODE_DIR)/tool/tool_chain_gcc_patches.inc
$(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION)/configure: $(DOWNLOAD_DIR)/$(BINUTILS_DOWNLOAD_TBZ2)
$(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION): $(addprefix $(DOWNLOAD_DIR)/,$(BINUTILS_DOWNLOAD_TBZ2))
$(ECHO) "$(BRIGHT_COL)unpacking binutils...$(DEFAULT_COL)"
$(VERBOSE)mkdir -p $(CONTRIB_DIR)
$(VERBOSE)tar xfj $^ -C $(CONTRIB_DIR) && touch $@
include $(GENODE_DIR)/tool/tool_chain_binutils_patches.inc
build/$(PLATFORM)/binutils/Makefile: $(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION)/configure
$(ECHO) "$(BRIGHT_COL)configuring binutils...$(DEFAULT_COL)"
$(VERBOSE)mkdir -p $(dir $@)

View File

@ -0,0 +1,12 @@
BINUTILS_PATCHES_DIR = $(GENODE_DIR)/tool/patches/binutils-$(BINUTILS_VERSION)
BINUTILS_PATCHES = $(shell cat $(BINUTILS_PATCHES_DIR)/series)
$(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION)/configure:: $(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION)
$(ECHO) "$(BRIGHT_COL)patching binutils build system...$(DEFAULT_COL)"
$(VERBOSE)for p in $(BINUTILS_PATCHES); do \
patch -d $(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION) -p1 -i $(BINUTILS_PATCHES_DIR)/$$p; done;
@#
@# Re-generate configure scripts
@#
$(VERBOSE)cd $(CONTRIB_DIR)/binutils-$(BINUTILS_VERSION)/bfd; $(AUTOCONF)
$(VERBOSE)touch $@