From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26338 invoked by alias); 19 Mar 2014 13:31:55 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 26321 invoked by uid 89); 19 Mar 2014 13:31:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Mar 2014 13:31:53 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2JDVppR009590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Mar 2014 09:31:52 -0400 Received: from [10.36.5.55] (vpn1-5-55.ams2.redhat.com [10.36.5.55]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2JDVl2t008742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 19 Mar 2014 09:31:50 -0400 Message-ID: <53299C43.8040607@redhat.com> Date: Wed, 19 Mar 2014 13:31:00 -0000 From: Nicholas Clifton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: daniel.gutson@tallertechnologies.com CC: binutils@sourceware.org Subject: Re: [PATCH] add CodeComposer Studio assembly syntax compatibility support References: <240112064-1393947412-cardhu_decombobulator_blackberry.rim.net-1332958159-@b28.c15.bise6.blackberry> <53162C0E.6080002@eagerm.com> <604343986-1393969065-cardhu_decombobulator_blackberry.rim.net-1475874685-@b28.c15.bise6.blackberry> <564843056-1394800165-cardhu_decombobulator_blackberry.rim.net-1498109565-@b28.c15.bise6.blackberry> <1168996588-1395223994-cardhu_decombobulator_blackberry.rim.net-959557934-@b28.c15.bise6.blackberry> In-Reply-To: <1168996588-1395223994-cardhu_decombobulator_blackberry.rim.net-959557934-@b28.c15.bise6.blackberry> Content-Type: multipart/mixed; boundary="------------020801090204010800080309" X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00203.txt.bz2 This is a multi-part message in MIME format. --------------020801090204010800080309 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 665 Hi Daniel, Sorry for the long delay in reviewing this patch. Unfortunately I do not like the approach of converting the comment_chars and line_separator_chars arrays in *all* targets to non-constant versions. GAS already has a solution for the comment_chars array - defining tc_comment_chars - and it is a relatively simply affair to extend this to handle line_separator_chars as well. Also your patch adds a new command line option -mccs, but it does not include any documentation of it in gas/doc/c-arm.texi or gas/NEWS. So... please have a look at the attached variant patch and let me know if this is acceptable to you. Cheers Nick --------------020801090204010800080309 Content-Type: text/x-patch; name="arm.ccs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="arm.ccs.patch" Content-length: 10372 diff --git a/gas/NEWS b/gas/NEWS index 7e2a5d0..0a4430c 100644 --- 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: diff --git a/gas/app.c b/gas/app.c index 81e6b9d..32a172f 100644 --- 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 diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index bdcfb5c..69299c7 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -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 } }; @@ -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_("\t assemble for CPU "), @@ -24539,6 +24690,8 @@ struct arm_long_option_table arm_long_opts[] = #endif {"mimplicit-it=", N_("\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} }; diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index ea07801..f88fa29 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -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[]; diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index efeac93..5c8b000 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -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 diff --git a/gas/doc/c-arm.texi b/gas/doc/c-arm.texi index c79c43b..7bcce94 100644 --- a/gas/doc/c-arm.texi +++ b/gas/doc/c-arm.texi @@ -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 diff --git a/gas/doc/internals.texi b/gas/doc/internals.texi index d76c90e..76f812d 100644 --- a/gas/doc/internals.texi +++ b/gas/doc/internals.texi @@ -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 diff --git a/gas/read.c b/gas/read.c index b4aa391..08b129f 100644 --- a/gas/read.c +++ b/gas/read.c @@ -263,8 +263,11 @@ read_begin (void) obstack_begin (¬es, 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. */ --------------020801090204010800080309--