RISC-V: Don't emit 2-byte NOPs if the C extension is disabled
authorPalmer Dabbelt <palmer@dabbelt.com>
Fri, 6 Oct 2017 19:06:45 +0000 (12:06 -0700)
committerPalmer Dabbelt <palmer@dabbelt.com>
Tue, 24 Oct 2017 01:26:29 +0000 (18:26 -0700)
Systems without the C extension mandate 4-byte alignment for
instructions, so there is no reason to allow for 2-byte alignment.  This
change avoids emitting lots of unimplemented instructions into object
files on non-C targets, which users keep reporting as a bug.  While this
isn't actually a bug (as none of the offsets in object files are
relevant until RISC-V), it is ugly.

gas/ChangeLog

2017-10-23  Palmer Dabbelt  <palmer@dabbelt.com>

        * config/tc-riscv.c (riscv_frag_align_code): Align code by 4
        bytes on non-RVC systems.

gas/ChangeLog
gas/config/tc-riscv.c

index f095421ee62ea2db7668c210055db799c2767365..bb1aa01da91aad6098d5884566ac9bcc6ed22e76 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-23  Palmer Dabbelt  <palmer@dabbelt.com>
+
+        * config/tc-riscv.c (riscv_frag_align_code): Align code by 4
+        bytes on non-RVC systems.
+
 2017-10-23  Maciej W. Rozycki  <macro@imgtec.com>
 
        * config/tc-mips.c (mips_elf_final_processing): Don't set
index 189e40d11c7f9cd82d6a1d512746305f5faa6dac..f4276c9fb5eb02f9e3cc21ef9a1c5fdb15fa9397 100644 (file)
@@ -2277,7 +2277,7 @@ bfd_boolean
 riscv_frag_align_code (int n)
 {
   bfd_vma bytes = (bfd_vma) 1 << n;
-  bfd_vma worst_case_bytes = bytes - 2;
+  bfd_vma worst_case_bytes = bytes - (riscv_opts.rvc ? 2 : 4);
   char *nops = frag_more (worst_case_bytes);
   expressionS ex;
 
This page took 0.047235 seconds and 4 git commands to generate.