]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add support for ARM assembler produced by CodeCompositor Studio.
authorDaniel Gutson <daniel.gutson@tallertechnologies.com>
Wed, 19 Mar 2014 14:31:25 +0000 (14:31 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 19 Mar 2014 14:31:25 +0000 (14:31 +0000)
* config/tc-arm.c (codecomposer_syntax): New flag that states whether the
CCS syntax compatibility mode is on or off.
(asmfunc_states): New enum to represent the asmfunc directive state.
(asmfunc_state): New variable holding the asmfunc directive state.
(comment_chars): Rename to arm_comment_chars.
(line_separator_chars): Rename to arm_line_separator_chars.
(s_ccs_ref): New function that handles the .ref directive.
(asmfunc_debug): New function.
(s_ccs_asmfunc): New function that handles the .asmfunc directive.
(s_ccs_endasmfunc): New function that handles the .endasmfunc directive.
(s_ccs_def): New function that handles the .def directive.
(tc_start_label_without_colon): New function.
(md_pseudo_table): Added new CCS directives.
(arm_ccs_mode): New function that handles the -mccs command line option.
(arm_long_opts): Added new -mccs command line option.
* config/tc-arm.h (LABELS_WITHOUT_COLONS): New macro.
(TC_START_LABEL_WITHOUT_COLON): New macro.
(tc_start_label_without_colon): Added extern function declaration.
(tc_comment_chars): Define.
(tc_line_separator_chars): Define.
* app.c (do_scrub_begin): Use tc_line_separator_chars, if defined.
* read.c (read_begin): Likewise.
* doc/as.texinfo: Add documentation for the -mccs command line
option.
* doc/c-arm.texi: Likewise.
* doc/internals.texi: Document tc_line_separator_chars.
* NEWS: Mention the new feature.

* gas/arm/ccs.s: New test case.
* gas/arm/ccs.d: New expected disassembly.

12 files changed:
gas/ChangeLog
gas/NEWS
gas/app.c
gas/config/tc-arm.c
gas/config/tc-arm.h
gas/doc/as.texinfo
gas/doc/c-arm.texi
gas/doc/internals.texi
gas/read.c
gas/testsuite/ChangeLog
gas/testsuite/gas/arm/ccs.d [new file with mode: 0644]
gas/testsuite/gas/arm/ccs.s [new file with mode: 0644]

index fc09a868b165c415288f0ce8abaa01324dd830b8..96363fd30269550c130d1ae310463d8448b6c686 100644 (file)
@@ -1,3 +1,34 @@
+2014-03-19  Daniel Gutson <daniel.gutson@tallertechnologies.com>`
+           Nick Clifton  <nickc@redhat.com>
+
+       * config/tc-arm.c (codecomposer_syntax): New flag that states whether the
+       CCS syntax compatibility mode is on or off.
+       (asmfunc_states): New enum to represent the asmfunc directive state.
+       (asmfunc_state): New variable holding the asmfunc directive state.
+       (comment_chars): Rename to arm_comment_chars.
+       (line_separator_chars): Rename to arm_line_separator_chars.
+       (s_ccs_ref): New function that handles the .ref directive.
+       (asmfunc_debug): New function.
+       (s_ccs_asmfunc): New function that handles the .asmfunc directive.
+       (s_ccs_endasmfunc): New function that handles the .endasmfunc directive.
+       (s_ccs_def): New function that handles the .def directive.
+       (tc_start_label_without_colon): New function.
+       (md_pseudo_table): Added new CCS directives.
+       (arm_ccs_mode): New function that handles the -mccs command line option.
+       (arm_long_opts): Added new -mccs command line option.
+       * config/tc-arm.h (LABELS_WITHOUT_COLONS): New macro.
+       (TC_START_LABEL_WITHOUT_COLON): New macro.
+       (tc_start_label_without_colon): Added extern function declaration.
+       (tc_comment_chars): Define.
+       (tc_line_separator_chars): Define.
+       * app.c (do_scrub_begin): Use tc_line_separator_chars, if defined.
+       * read.c (read_begin): Likewise.
+       * doc/as.texinfo: Add documentation for the -mccs command line
+       option.
+       * doc/c-arm.texi: Likewise.
+       * doc/internals.texi: Document tc_line_separator_chars.
+       * NEWS: Mention the new feature.
+
 2014-03-18  Jiong Wang  <jiong.wang@arm.com>
 
        * config/tc-aarch64.c (aarch64_opts): Add new option
index 7e2a5d0ff71ea921d443bbc20c23d56cbef22017..0a4430cdd06bb893504bd0ddb1fd56b3d7b5798d 100644 (file)
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,5 +1,8 @@
 -*- text -*-
 
+* Enhanced the ARM port to accept the assembler output from the CodeComposer
+  Studio tool.  Support is enabled via the new command line option -mccs.
+
 * Add support for the Andes NDS32.
 
 Changes in 2.24:
index 81e6b9dbd43af733a714c902b0fb46bb075fdff6..32a172f55dd8d462f16eb6a9a6752e0624a3da59 100644 (file)
--- a/gas/app.c
+++ b/gas/app.c
@@ -158,7 +158,10 @@ do_scrub_begin (int m68k_mri ATTRIBUTE_UNUSED)
   for (p = line_comment_chars; *p; p++)
     lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START;
 
-  for (p = line_separator_chars; *p; p++)
+#ifndef tc_line_separator_chars
+#define tc_line_separator_chars line_separator_chars
+#endif
+  for (p = tc_line_separator_chars; *p; p++)
     lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR;
 
 #ifdef tc_parallel_separator_chars
index bdcfb5c0d95dfe67473c255fa1b3a3ce1c30d2c3..69299c7b1cb7ff1aa11bffcd9f50cce91fbf2b53 100644 (file)
@@ -137,6 +137,8 @@ static int fix_v4bx      = FALSE;
 /* Warn on using deprecated features.  */
 static int warn_on_deprecated = TRUE;
 
+/* Understand CodeComposer Studio assembly syntax.  */
+bfd_boolean codecomposer_syntax = FALSE;
 
 /* Variables that we set while parsing command-line options.  Once all
    options have been read we re-process these values to set the real
@@ -795,6 +797,15 @@ typedef struct literal_pool
 /* Pointer to a linked list of literal pools.  */
 literal_pool * list_of_pools = NULL;
 
+typedef enum asmfunc_states
+{
+  OUTSIDE_ASMFUNC,
+  WAITING_ASMFUNC_NAME,
+  WAITING_ENDASMFUNC
+} asmfunc_states;
+
+static asmfunc_states asmfunc_state = OUTSIDE_ASMFUNC;
+
 #ifdef OBJ_ELF
 #  define now_it seg_info (now_seg)->tc_segment_info_data.current_it
 #else
@@ -853,7 +864,7 @@ static void it_fsm_post_encode (void);
 
 /* This array holds the chars that always start a comment.  If the
    pre-processor is disabled, these aren't very useful.         */
-const char comment_chars[] = "@";
+char arm_comment_chars[] = "@";
 
 /* This array holds the chars that only start a comment at the beginning of
    a line.  If the line seems to have the form '# 123 filename'
@@ -864,7 +875,7 @@ const char comment_chars[] = "@";
 /* Also note that comments like this one will always work.  */
 const char line_comment_chars[] = "#";
 
-const char line_separator_chars[] = ";";
+char arm_line_separator_chars[] = ";";
 
 /* Chars that can be used to separate mant
    from exp in floating point numbers. */
@@ -3012,6 +3023,104 @@ s_even (int ignore ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+/* Directives: CodeComposer Studio.  */
+
+/*  .ref  (for CodeComposer Studio syntax only).  */
+static void
+s_ccs_ref (int unused ATTRIBUTE_UNUSED)
+{
+  if (codecomposer_syntax)
+    ignore_rest_of_line ();
+  else
+    as_bad (_(".ref pseudo-op only available with -mccs flag."));
+}
+
+/*  If name is not NULL, then it is used for marking the beginning of a
+    function, wherease if it is NULL then it means the function end.  */
+static void
+asmfunc_debug (const char * name)
+{
+  static const char * last_name = NULL;
+
+  if (name != NULL)
+    {
+      gas_assert (last_name == NULL);
+      last_name = name;
+
+      if (debug_type == DEBUG_STABS)
+         stabs_generate_asm_func (name, name);
+    }
+  else
+    {
+      gas_assert (last_name != NULL);
+
+      if (debug_type == DEBUG_STABS)
+        stabs_generate_asm_endfunc (last_name, last_name);
+
+      last_name = NULL;
+    }
+}
+
+static void
+s_ccs_asmfunc (int unused ATTRIBUTE_UNUSED)
+{
+  if (codecomposer_syntax)
+    {
+      switch (asmfunc_state)
+       {
+       case OUTSIDE_ASMFUNC:
+         asmfunc_state = WAITING_ASMFUNC_NAME;
+         break;
+
+       case WAITING_ASMFUNC_NAME:
+         as_bad (_(".asmfunc repeated."));
+         break;
+
+       case WAITING_ENDASMFUNC:
+         as_bad (_(".asmfunc without function."));
+         break;
+       }
+      demand_empty_rest_of_line ();
+    }
+  else
+    as_bad (_(".asmfunc pseudo-op only available with -mccs flag."));
+}
+
+static void
+s_ccs_endasmfunc (int unused ATTRIBUTE_UNUSED)
+{
+  if (codecomposer_syntax)
+    {
+      switch (asmfunc_state)
+       {
+       case OUTSIDE_ASMFUNC:
+         as_bad (_(".endasmfunc without a .asmfunc."));
+         break;
+
+       case WAITING_ASMFUNC_NAME:
+         as_bad (_(".endasmfunc without function."));
+         break;
+
+       case WAITING_ENDASMFUNC:
+         asmfunc_state = OUTSIDE_ASMFUNC;
+         asmfunc_debug (NULL);
+         break;
+       }
+      demand_empty_rest_of_line ();
+    }
+  else
+    as_bad (_(".endasmfunc pseudo-op only available with -mccs flag."));
+}
+
+static void
+s_ccs_def (int name)
+{
+  if (codecomposer_syntax)
+    s_globl (name);
+  else
+    as_bad (_(".def pseudo-op only available with -mccs flag."));
+}
+
 /* Directives: Literal pools.  */
 
 static literal_pool *
@@ -3128,6 +3237,32 @@ add_to_lit_pool (void)
   return SUCCESS;
 }
 
+bfd_boolean
+tc_start_label_without_colon (char unused1 ATTRIBUTE_UNUSED, const char * rest)
+{
+  bfd_boolean ret = TRUE;
+
+  if (codecomposer_syntax && asmfunc_state == WAITING_ASMFUNC_NAME)
+    {
+      const char *label = rest;
+
+      while (!is_end_of_line[(int) label[-1]])
+       --label;
+
+      if (*label == '.')
+       {
+         as_bad (_("Invalid label '%s'"), label);
+         ret = FALSE;
+       }
+
+      asmfunc_debug (label);
+
+      asmfunc_state = WAITING_ENDASMFUNC;
+    }
+
+  return ret;
+}
+
 /* Can't use symbol_new here, so have to create a symbol and then at
    a later date assign it a value. Thats what these functions do.  */
 
@@ -4486,6 +4621,13 @@ const pseudo_typeS md_pseudo_table[] =
 #ifdef TE_PE
   {"secrel32", pe_directive_secrel, 0},
 #endif
+
+  /* These are for compatibility with CodeComposer Studio.  */
+  {"ref",          s_ccs_ref,        0},
+  {"def",          s_ccs_def,        0},
+  {"asmfunc",      s_ccs_asmfunc,    0},
+  {"endasmfunc",   s_ccs_endasmfunc, 0},
+
   { 0, 0, 0 }
 };
 \f
@@ -24523,6 +24665,15 @@ arm_parse_it_mode (char * str)
   return ret;
 }
 
+static bfd_boolean
+arm_ccs_mode (char * unused ATTRIBUTE_UNUSED)
+{
+  codecomposer_syntax = TRUE;
+  arm_comment_chars[0] = ';';
+  arm_line_separator_chars[0] = 0;
+  return TRUE;
+}
+
 struct arm_long_option_table arm_long_opts[] =
 {
   {"mcpu=", N_("<cpu name>\t  assemble for CPU <cpu name>"),
@@ -24539,6 +24690,8 @@ struct arm_long_option_table arm_long_opts[] =
 #endif
   {"mimplicit-it=", N_("<mode>\t  controls implicit insertion of IT instructions"),
    arm_parse_it_mode, NULL},
+  {"mccs", N_("\t\t\t  TI CodeComposer Studio syntax compatibility mode"),
+   arm_ccs_mode, NULL},
   {NULL, NULL, 0, NULL}
 };
 
index ea078015a084cfed59a77c840e586b43df2fc6d3..f88fa2976114a7b338eefe75e7d17455cfe769bd 100644 (file)
@@ -81,6 +81,10 @@ struct fix;
 /* We support double slash line-comments for compatibility with the ARM AArch64 Assembler.  */
 #define DOUBLESLASH_LINE_COMMENTS
 
+/* We conditionally support labels without a colon.  */
+#define LABELS_WITHOUT_COLONS codecomposer_syntax
+extern bfd_boolean codecomposer_syntax;
+
 #define tc_symbol_chars arm_symbol_chars
 extern const char arm_symbol_chars[];
 
@@ -100,6 +104,9 @@ extern int arm_optimize_expr (expressionS *, operatorT, expressionS *);
 
 #define md_start_line_hook() arm_start_line_hook ()
 
+#define TC_START_LABEL_WITHOUT_COLON(c, l)  tc_start_label_without_colon (c, l)
+extern bfd_boolean tc_start_label_without_colon (char, const char *);
+
 #define tc_frob_label(S) arm_frob_label (S)
 
 /* We also need to mark assembler created symbols:  */
@@ -363,3 +370,9 @@ void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
 extern int arm_convert_symbolic_attribute (const char *);
 extern int arm_apply_sym_value (struct fix *);
 #endif
+
+#define tc_comment_chars arm_comment_chars
+extern char arm_comment_chars[];
+
+#define tc_line_separator_chars arm_line_separator_chars
+extern char arm_line_separator_chars[];
index efeac93ecc4a9c4a7a41c92e568d29380a18efb2..5c8b000f60ff6c53ac28dd52c7e2948a90cb5dfd 100644 (file)
@@ -848,6 +848,8 @@ Select either big-endian (-EB) or little-endian (-EL) output.
 @item -mthumb-interwork
 Specify that the code has been generated with interworking between Thumb and
 ARM code in mind.
+@item -mccs
+Turns on CodeComposer Studio assembly syntax compatibility mode.
 @item -k
 Specify that PIC code has been generated.
 @end table
index c79c43b5d0a8ccf70d43ce70d6868be6a6e01881..7bcce943d10e71c5e46d120ce418d01107e561bc 100644 (file)
@@ -369,6 +369,10 @@ the linker option of the same name.
 Enable or disable warnings about using deprecated options or
 features.  The default is to warn.
 
+@cindex @code{-mccs} command line option, ARM
+@item -mccs
+Turns on CodeComposer Studio assembly syntax compatibility mode.
+
 @end table
 
 
index d76c90ee01982ad442429fd4b3e73dc41123474e..76f812da03cd9a4a4700868c69038e4b83c2b5e0 100644 (file)
@@ -884,6 +884,8 @@ comment.
 @item tc_comment_chars
 @cindex tc_comment_chars
 If this macro is defined, GAS will use it instead of @code{comment_chars}.
+This has the advantage that this macro does not have to refer to a constant
+array.
 
 @item tc_symbol_chars
 @cindex tc_symbol_chars
@@ -908,6 +910,13 @@ listed in this array).  Note that line_separator_chars do not separate lines
 if found in a comment, such as after a character in line_comment_chars or
 comment_chars.
 
+@item tc_line_separator_chars
+@cindex tc_line_separator_chars
+If this macro is defined, GAS will use it instead of
+@code{line_separator_chars}.  This has the advantage that this macro does not
+have to refer to a constant array.
+
+
 @item EXP_CHARS
 @cindex EXP_CHARS
 This is a null terminated @code{const char} array of characters which may be
index b4aa3912d06e5e6a30e7298c913e75a3bfbee12e..08b129f0805309dc4acebff3c2bc9aff5a19b824 100644 (file)
@@ -263,8 +263,11 @@ read_begin (void)
   obstack_begin (&notes, chunksize);
   obstack_begin (&cond_obstack, chunksize);
 
+#ifndef tc_line_separator_chars
+#define tc_line_separator_chars line_separator_chars
+#endif
   /* Use machine dependent syntax.  */
-  for (p = line_separator_chars; *p; p++)
+  for (p = tc_line_separator_chars; *p; p++)
     is_end_of_line[(unsigned char) *p] = 2;
   /* Use more.  FIXME-SOMEDAY.  */
 
index 782e2a14fa503b3b79e1aa9ba88612228c598c7f..5cb3e17e8de39756127e50b3e49f0bd881fc2228 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-19  Daniel Gutson <daniel.gutson@tallertechnologies.com>`
+           Nick Clifton  <nickc@redhat.com>
+
+       * gas/arm/ccs.s: New test case.
+       * gas/arm/ccs.d: New expected disassembly.
+
 2014-03-19  Nick Clifton  <nickc@redhat.com>
 
        * gas/rx/mov.d: Update expected disassembly.
diff --git a/gas/testsuite/gas/arm/ccs.d b/gas/testsuite/gas/arm/ccs.d
new file mode 100644 (file)
index 0000000..742993b
--- /dev/null
@@ -0,0 +1,25 @@
+#objdump: -dr
+# as: -mccs -mcpu=cortex-r4 -mthumb
+
+.*:     file format .*arm.*
+
+
+Disassembly of section \.text:
+
+00000000 <_test_func>:
+   0:  e92d5fff        push    {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr}
+   4:  e59fc018        ldr     ip, \[pc, #24\] ; 24 <sym1>
+   8:  e59c0000        ldr     r0, \[ip\]
+   c:  e3100008        tst     r0, #8
+  10:  1a000000        bne     18 <aLabel>
+  14:  e59c0000        ldr     r0, \[ip\]
+
+00000018 <aLabel>:
+  18:  eb......        bl      . <ext_sy.*>
+                       18: .*  ext_sy.*
+  1c:  e8bd5fff        pop     {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr}
+  20:  e25ef008        subs    pc, lr, #8
+
+00000024 <sym1>:
+  24:  fffff520        .*
+#...
diff --git a/gas/testsuite/gas/arm/ccs.s b/gas/testsuite/gas/arm/ccs.s
new file mode 100644 (file)
index 0000000..3a7568a
--- /dev/null
@@ -0,0 +1,33 @@
+;-------------------------------------------------------------------------------
+; Comments here
+
+    .text
+    .arm
+
+;-------------------------------------------------------------------------------
+
+    .ref       ext_sym
+    .def       _test_func
+    .asmfunc
+
+_test_func
+               stmfd   r13!, {r0 - r12, lr}; push registers and link register on to stack
+
+        ldr            r12, sym1                       ; another comment
+        ldr            r0,  [r12]
+        tst            r0,  #0x8
+        bne            aLabel
+        ldr            r0,  [r12]
+
+aLabel
+               bl              ext_sym         ; custom data abort handler required
+
+               ldmfd   r13!, {r0 - r12, lr}; pop registers and link register from stack
+               subs    pc, lr, #8
+
+sym1           .word   0xFFFFF520
+
+
+    .endasmfunc
+       
+