From 5d6d29f4412796e7f98a000dfffb51b2397283fd Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Tue, 5 Apr 2016 16:40:18 -0700 Subject: Set the RISC-V ISA version to 2 This is what the manual says. Note that we don't actually do anything with this version number. --- binutils/gas/config/tc-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'binutils') diff --git a/binutils/gas/config/tc-riscv.c b/binutils/gas/config/tc-riscv.c index 90d3c4b..0bf5f85 100644 --- a/binutils/gas/config/tc-riscv.c +++ b/binutils/gas/config/tc-riscv.c @@ -125,7 +125,7 @@ riscv_add_subset (const char *subset) { struct riscv_subset *s = xmalloc (sizeof *s); s->name = xstrdup (subset); - s->version_major = 1; + s->version_major = 2; s->version_minor = 0; s->next = riscv_subsets; riscv_subsets = s; -- cgit v1.1 From 68a04d8311e6db57d2088a488e34229809a6aad9 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Tue, 5 Apr 2016 16:41:29 -0700 Subject: Revamp binutils' handling of -msoft-float and -march binutils used to ignore -march when calculating the ELF header. This means would cause linking problems when trying to link together libraries generated using the two different ways of specifying the floating-point ABI. With this patch, binutils respects -march when it's specified but allows -msoft-float to override that setting. It's an error to pass -mhard-float to an ISA without F/D. --- binutils/gas/config/tc-riscv.c | 43 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'binutils') diff --git a/binutils/gas/config/tc-riscv.c b/binutils/gas/config/tc-riscv.c index 0bf5f85..6e60c37 100644 --- a/binutils/gas/config/tc-riscv.c +++ b/binutils/gas/config/tc-riscv.c @@ -1778,6 +1778,13 @@ struct option md_longopts[] = }; size_t md_longopts_size = sizeof (md_longopts); +enum float_mode { + FLOAT_MODE_DEFAULT, + FLOAT_MODE_SOFT, + FLOAT_MODE_HARD +}; +static enum float_mode marg_float_mode = FLOAT_MODE_DEFAULT; + int md_parse_option (int c, char *arg) { @@ -1792,11 +1799,11 @@ md_parse_option (int c, char *arg) break; case OPTION_MSOFT_FLOAT: - elf_flags |= EF_RISCV_SOFT_FLOAT; + marg_float_mode = FLOAT_MODE_SOFT; break; case OPTION_MHARD_FLOAT: - elf_flags &= ~EF_RISCV_SOFT_FLOAT; + marg_float_mode = FLOAT_MODE_HARD; break; case OPTION_M32: @@ -1829,6 +1836,9 @@ md_parse_option (int c, char *arg) void riscv_after_parse_args (void) { + struct riscv_subset *subset; + enum float_mode isa_float_mode, elf_float_mode; + if (riscv_subsets == NULL) riscv_set_arch ("RVIMAFDXcustom"); @@ -1841,6 +1851,35 @@ riscv_after_parse_args (void) else as_bad ("unknown default architecture `%s'", default_arch); } + + isa_float_mode = FLOAT_MODE_SOFT; + for (subset = riscv_subsets; subset != NULL; subset = subset->next) + { + if (strcasecmp(subset->name, "F") == 0) + isa_float_mode = FLOAT_MODE_HARD; + if (strcasecmp(subset->name, "D") == 0) + isa_float_mode = FLOAT_MODE_HARD; + } + + if (marg_float_mode == FLOAT_MODE_HARD && isa_float_mode == FLOAT_MODE_SOFT) + as_bad ("Architecture doesn't allow hardfloat ABI"); + + elf_float_mode = (marg_float_mode == FLOAT_MODE_DEFAULT) ? isa_float_mode + : marg_float_mode; + + switch (elf_float_mode) { + case FLOAT_MODE_DEFAULT: + as_bad("a specific float mode must be specified for an ELF"); + break; + + case FLOAT_MODE_SOFT: + elf_flags |= EF_RISCV_SOFT_FLOAT; + break; + + case FLOAT_MODE_HARD: + elf_flags &= ~EF_RISCV_SOFT_FLOAT; + break; + } } void -- cgit v1.1