Add support to the RX toolchain to restrict the use of string instructions.
authorNick Clifton <nickc@redhat.com>
Thu, 9 Apr 2015 11:48:37 +0000 (12:48 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 9 Apr 2015 11:48:37 +0000 (12:48 +0100)
bfd * elf32-rx.c (describe_flags): Report the settings of the string
insn using bits.
(rx_elf_merge_private_bfd_data): Handle merging of the string insn
using bits.

bin * readelf.c (get_machine_flags): Report the setting of the string
insn using bits.

gas * config/tc-rx.c (enum options): Add OPTION_DISALLOW_STRING_INSNS.
(md_longopts): Add -mno-allow-string-insns.
(md_parse_option): Handle -mno-allow-string-insns.
(md_show_usage): Mention -mno-allow-string-insns.
(rx_note_string_insn_use): New function.  Produces an error
message if a string insn is used when it is not allowed.
* config/rx-parse.y (SCMPU): Call rx_note_string_insn_use.
(SMOVU, SMOVB, SMOVF, SUNTIL, SWHILE, RMPA): Likewise.
* config/rx-defs.h (rx_note_string_insn_use): Prototype.
* doc/c-rx.texi: Document -mno-allow-string-insns.

elf * rx.h (E_FLAG_RX_SINSNS_SET): New bit in e_flags field.
(E_FLAG_RX_SINSNS_YES): Likewise.
(E_FLAG_RX_SINSNS_MASK): New define.

bfd/ChangeLog
bfd/elf32-rx.c
binutils/ChangeLog
binutils/readelf.c
gas/ChangeLog
gas/config/rx-defs.h
gas/config/rx-parse.y
gas/config/tc-rx.c
gas/doc/c-rx.texi
include/elf/ChangeLog
include/elf/rx.h

index c7050af943b38c1e4e5e9a85013773e449b0aecf..f2afc933e2881e62ad40cff55dff2b65e6607ef1 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-09  Nick Clifton  <nickc@redhat.com>
+
+       * elf32-rx.c (describe_flags): Report the settings of the string
+       insn using bits.
+       (rx_elf_merge_private_bfd_data): Handle merging of the string insn
+       using bits.
+
 2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        * compress.c (bfd_compress_section_contents): Work around a GCC
index b8c632e2994c91605f48cd2bfd7e619f4e8703d3..8d7162885acc68e51b5924e481f677ae90fada5f 100644 (file)
@@ -3086,6 +3086,9 @@ describe_flags (flagword flags)
   else
     strcat (buf, ", GCC ABI");
 
+  if (flags & E_FLAG_RX_SINSNS_SET)
+    strcat (buf, flags & E_FLAG_RX_SINSNS_YES ? ", uses String instructions" : ", bans String instructions");
+
   return buf;
 }
 
@@ -3112,8 +3115,22 @@ rx_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
     {
       flagword known_flags;
 
+      if (old_flags & E_FLAG_RX_SINSNS_SET)
+       {
+         if ((new_flags & E_FLAG_RX_SINSNS_SET) == 0)
+           {
+             new_flags &= ~ E_FLAG_RX_SINSNS_MASK;
+             new_flags |= (old_flags & E_FLAG_RX_SINSNS_MASK);
+           }
+       }
+      else if (new_flags & E_FLAG_RX_SINSNS_SET)
+       {
+         old_flags &= ~ E_FLAG_RX_SINSNS_MASK;
+         old_flags |= (new_flags & E_FLAG_RX_SINSNS_MASK);
+       }
+
       known_flags = E_FLAG_RX_ABI | E_FLAG_RX_64BIT_DOUBLES
-       | E_FLAG_RX_DSP | E_FLAG_RX_PID;
+       | E_FLAG_RX_DSP | E_FLAG_RX_PID | E_FLAG_RX_SINSNS_MASK;
 
       if ((old_flags ^ new_flags) & known_flags)
        {
index 7d5b1a092fd3a1b1cf0dd412b11b3ba4827f5d31..b2a81e5ab258f30d1db7621d3d268ba53043ad8b 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-09  Nick Clifton  <nickc@redhat.com>
+
+       * readelf.c (get_machine_flags): Report the setting of the string
+       insn using bits.
+
 2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        * objcopy.c (do_debug_sections): Add compress_zlib,
index fea372fd4bb449b98595a412d56bd2db724b5005..db69b5df40d5a9d4e98c081cc78913a1faf6dec2 100644 (file)
@@ -3274,6 +3274,9 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
            strcat (buf, ", pid");
          if (e_flags & E_FLAG_RX_ABI)
            strcat (buf, ", RX ABI");
+         if (e_flags & E_FLAG_RX_SINSNS_SET)
+           strcat (buf, e_flags & E_FLAG_RX_SINSNS_YES
+                   ? ", uses String instructions" : ", bans String instructions");
          break;
 
        case EM_S390:
index 7ff56c16a4d7a53465bb451a30cd1623306fe61d..de9a3c584df4b4e101ee01024f5332f88169938d 100644 (file)
@@ -1,3 +1,16 @@
+2015-04-09  Nick Clifton  <nickc@redhat.com>
+
+       * config/tc-rx.c (enum options): Add OPTION_DISALLOW_STRING_INSNS.
+       (md_longopts): Add -mno-allow-string-insns.
+       (md_parse_option): Handle -mno-allow-string-insns.
+       (md_show_usage): Mention -mno-allow-string-insns.
+       (rx_note_string_insn_use): New function.  Produces an error
+       message if a string insn is used when it is not allowed.
+       * config/rx-parse.y (SCMPU): Call rx_note_string_insn_use.
+       (SMOVU, SMOVB, SMOVF, SUNTIL, SWHILE, RMPA): Likewise.
+       * config/rx-defs.h (rx_note_string_insn_use): Prototype.
+       * doc/c-rx.texi: Document -mno-allow-string-insns.
+
 2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        * as.c (show_usage): Update --compress-debug-sections.
index 2a15b6c1863f6b82ff88f8d92629a0077f683530..15c447df0a7f1716a3f69770c6e8c8a400a8074b 100644 (file)
@@ -62,6 +62,7 @@ extern void   rx_linkrelax_imm (int);
 extern void   rx_linkrelax_branch (void);
 extern int    rx_parse (void);
 extern int    rx_wrap (void);
+extern void   rx_note_string_insn_use (void);
 
 extern char * rx_lex_start;
 extern char * rx_lex_end;
index 645ec99f5383fa0de8a105d1c6824f9a02914f90..5269d6641b6e7824a6aa788109a0c56f417645ec 100644 (file)
@@ -500,27 +500,27 @@ statement :
 /* ---------------------------------------------------------------------- */
 
        | SCMPU
-         { B2 (0x7f, 0x83); }
+         { B2 (0x7f, 0x83); rx_note_string_insn_use (); }
        | SMOVU
-         { B2 (0x7f, 0x87); }
+         { B2 (0x7f, 0x87); rx_note_string_insn_use (); }
        | SMOVB
-         { B2 (0x7f, 0x8b); }
+         { B2 (0x7f, 0x8b); rx_note_string_insn_use (); }
        | SMOVF
-         { B2 (0x7f, 0x8f); }
+         { B2 (0x7f, 0x8f); rx_note_string_insn_use (); }
 
 /* ---------------------------------------------------------------------- */
 
        | SUNTIL bwl
-         { B2 (0x7f, 0x80); F ($2, 14, 2); }
+         { B2 (0x7f, 0x80); F ($2, 14, 2); rx_note_string_insn_use (); }
        | SWHILE bwl
-         { B2 (0x7f, 0x84); F ($2, 14, 2); }
+         { B2 (0x7f, 0x84); F ($2, 14, 2); rx_note_string_insn_use (); }
        | SSTR bwl
          { B2 (0x7f, 0x88); F ($2, 14, 2); }
 
 /* ---------------------------------------------------------------------- */
 
        | RMPA bwl
-         { B2 (0x7f, 0x8c); F ($2, 14, 2); }
+         { B2 (0x7f, 0x8c); F ($2, 14, 2); rx_note_string_insn_use (); }
 
 /* ---------------------------------------------------------------------- */
 
index 2dec69fce44ddae31c14c52954f5c4f5ccc8806b..4e58f883cff77df8c65de87004d8d1efe2c8e77c 100644 (file)
@@ -73,6 +73,7 @@ enum options
   OPTION_USES_GCC_ABI,
   OPTION_USES_RX_ABI,
   OPTION_CPU,
+  OPTION_DISALLOW_STRING_INSNS,
 };
 
 #define RX_SHORTOPTS ""
@@ -99,7 +100,8 @@ struct option md_longopts[] =
   {"mint-register", required_argument, NULL, OPTION_INT_REGS},
   {"mgcc-abi", no_argument, NULL, OPTION_USES_GCC_ABI},
   {"mrx-abi", no_argument, NULL, OPTION_USES_RX_ABI},
-  {"mcpu",required_argument,NULL,OPTION_CPU},
+  {"mcpu", required_argument, NULL, OPTION_CPU},
+  {"mno-allow-string-insns", no_argument, NULL, OPTION_DISALLOW_STRING_INSNS},
   {NULL, no_argument, NULL, 0}
 };
 size_t md_longopts_size = sizeof (md_longopts);
@@ -173,6 +175,10 @@ md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED)
          break;
        }
       return 1;
+
+    case OPTION_DISALLOW_STRING_INSNS:
+      elf_flags |= E_FLAG_RX_SINSNS_SET | E_FLAG_RX_SINSNS_NO;
+      return 1;
     }
   return 0;
 }
@@ -192,6 +198,7 @@ md_show_usage (FILE * stream)
   fprintf (stream, _("  --mpid\n"));
   fprintf (stream, _("  --mint-register=<value>\n"));
   fprintf (stream, _("  --mcpu=<rx100|rx200|rx600|rx610>\n"));
+  fprintf (stream, _("  --mno-allow-string-insns"));
 }
 
 static void
@@ -2623,6 +2630,14 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
   return reloc;
 }
 
+void
+rx_note_string_insn_use (void)
+{
+  if ((elf_flags & E_FLAG_RX_SINSNS_MASK) == (E_FLAG_RX_SINSNS_SET | E_FLAG_RX_SINSNS_NO))
+    as_bad (_("Use of an RX string instruction detected in a file being assembled without string instruction support"));
+  elf_flags |= E_FLAG_RX_SINSNS_SET | E_FLAG_RX_SINSNS_YES;
+}
+
 /* Set the ELF specific flags.  */
 
 void
index 0eddb08b8caf6c88fff30a90e51638749951cdc4..abf15cd505edfb5610ea634a5be3869672c163e7 100644 (file)
@@ -112,6 +112,21 @@ This option tells the assembler the target CPU type.  Currently the
 cpu names.  Attempting to assemble an instruction not supported by the
 indicated cpu type will result in an error message being generated.
 
+@cindex @samp{-mno-allow-string-insns}
+@item -mno-allow-string-insns
+This option tells the assembler to mark the object file that it is
+building as one that does not use the string instructions
+@code{SMOVF}, @code{SCMPU}, @code {SMOVB}, @code{SMOVU}, @code{SUNTIL} 
+@code {SWHILE} or the @code {RMPA} instruction.  In addition the mark
+tells the linker to complain if an attempt is made to link the binary
+with another one that does use any of these instructions.
+
+Note - the inverse of this option, @code{-mallow-string-insns}, is
+not needed.  The assembler automatically detects the use of the
+the instructions in the source code and labels the resulting
+object file appropriately.  If no string instructions are detected
+then the object file is labelled as being one that can be linked with
+either string-using or string-banned object files.
 @end table
 
 @node RX-Modifiers
index 55bc60c64e0af1930c473f39876bcd03a7746a1d..d66e507282c80d69319d770747dd3e58ee9c008e 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-09  Nick Clifton  <nickc@redhat.com>
+
+       * rx.h (E_FLAG_RX_SINSNS_SET): New bit in e_flags field.
+       (E_FLAG_RX_SINSNS_YES): Likewise.
+       (E_FLAG_RX_SINSNS_MASK): New define.
+
 2015-04-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        * external.h (Elf32_External_Chdr): New.
index de367d245086f56029941dd7c823cc42eb5b2510..f945dac2ea532daf39468934711412335f421403 100644 (file)
@@ -120,6 +120,11 @@ END_RELOC_NUMBERS (R_RX_max)
 #define E_FLAG_RX_PID                  (1 << 2) /* Unofficial - DJ */
 #define E_FLAG_RX_ABI                  (1 << 3) /* Binary passes stacked arguments using natural alignment.  Unofficial - NC.  */
 
+#define E_FLAG_RX_SINSNS_SET           (1 << 6) /* Set if bit-5 is significant.  */
+#define E_FLAG_RX_SINSNS_YES           (1 << 7) /* Set if string instructions are used in the binary.  */
+#define E_FLAG_RX_SINSNS_NO            0        /* Bit-5 if this binary must not be linked with a string instruction using binary.  */
+#define E_FLAG_RX_SINSNS_MASK          (3 << 6) /* Mask of bits used to determine string instruction use.  */
+
 /* These define the addend field of R_RX_RH_RELAX relocations.  */
 #define        RX_RELAXA_IMM6  0x00000010      /* Imm8/16/24/32 at bit offset 6.  */
 #define        RX_RELAXA_IMM12 0x00000020      /* Imm8/16/24/32 at bit offset 12.  */
This page took 0.039415 seconds and 4 git commands to generate.