From 3525236c57a64fdbb534671fd2b16f9f846d36f3 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 9 Apr 2015 12:48:37 +0100 Subject: Add support to the RX toolchain to restrict the use of string instructions. 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. --- gas/ChangeLog | 13 +++++++++++++ gas/config/rx-defs.h | 1 + gas/config/rx-parse.y | 14 +++++++------- gas/config/tc-rx.c | 17 ++++++++++++++++- gas/doc/c-rx.texi | 15 +++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) (limited to 'gas') diff --git a/gas/ChangeLog b/gas/ChangeLog index 7ff56c1..de9a3c5 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,16 @@ +2015-04-09 Nick Clifton + + * 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 * as.c (show_usage): Update --compress-debug-sections. diff --git a/gas/config/rx-defs.h b/gas/config/rx-defs.h index 2a15b6c..15c447d 100644 --- a/gas/config/rx-defs.h +++ b/gas/config/rx-defs.h @@ -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; diff --git a/gas/config/rx-parse.y b/gas/config/rx-parse.y index 645ec99..5269d66 100644 --- a/gas/config/rx-parse.y +++ b/gas/config/rx-parse.y @@ -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 (); } /* ---------------------------------------------------------------------- */ diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c index 2dec69f..4e58f88 100644 --- a/gas/config/tc-rx.c +++ b/gas/config/tc-rx.c @@ -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=\n")); fprintf (stream, _(" --mcpu=\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 diff --git a/gas/doc/c-rx.texi b/gas/doc/c-rx.texi index 0eddb08..abf15cd 100644 --- a/gas/doc/c-rx.texi +++ b/gas/doc/c-rx.texi @@ -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 -- cgit v1.1