X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=gas%2Fconfig%2Ftc-tic54x.c;h=611b537e11d7f0f6f1611e55aaa39650a5f406c9;hb=4ec9d7d56427e9fa49fd705599bb2ff0c3c5f3c1;hp=68d541ac17b9fb2b2794b23ee31024c455b7bf69;hpb=5a49b8acf456d4a049c002fae31b83a10b35e6f8;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c index 68d541ac17..611b537e11 100644 --- a/gas/config/tc-tic54x.c +++ b/gas/config/tc-tic54x.c @@ -1,6 +1,5 @@ /* tc-tic54x.c -- Assembly code for the Texas Instruments TMS320C54X - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 - Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. Contributed by Timothy Wall (twall@cygnus.com) This file is part of GAS, the GNU Assembler. @@ -45,8 +44,8 @@ COFF1 limits section names to 8 characters. Some of the default behavior changed from COFF1 to COFF2. */ -#include #include "as.h" +#include #include "safe-ctype.h" #include "sb.h" #include "macro.h" @@ -81,7 +80,7 @@ static struct stag typedef struct _tic54x_insn { - const template *tm; /* Opcode template. */ + const insn_template *tm; /* Opcode template. */ char mnemonic[MAX_LINE]; /* Opcode name/mnemonic. */ char parmnemonic[MAX_LINE]; /* 2nd mnemonic of parallel insn. */ @@ -243,11 +242,11 @@ md_show_usage (FILE *stream) static void tic54x_emit_char (char c) { - expressionS exp; + expressionS expn; - exp.X_op = O_constant; - exp.X_add_number = c; - emit_expr (&exp, 2); + expn.X_op = O_constant; + expn.X_add_number = c; + emit_expr (&expn, 2); } /* Walk backwards in the frag chain. */ @@ -298,14 +297,14 @@ frag_bit_offset (fragS *frag, segT seg) expression. */ static char * -parse_expression (char *str, expressionS *exp) +parse_expression (char *str, expressionS *expn) { char *s; char *tmp; tmp = input_line_pointer; /* Save line pointer. */ input_line_pointer = str; - expression (exp); + expression (expn); s = input_line_pointer; input_line_pointer = tmp; /* Restore line pointer. */ return s; /* Return pointer to where parsing stopped. */ @@ -323,7 +322,6 @@ tic54x_asg (int x ATTRIBUTE_UNUSED) int c; char *name; char *str; - char *tmp; int quoted = *input_line_pointer == '"'; ILLEGAL_WITHIN_STRUCT (); @@ -352,23 +350,19 @@ tic54x_asg (int x ATTRIBUTE_UNUSED) return; } - name = ++input_line_pointer; - c = get_symbol_end (); /* Get terminator. */ + ++input_line_pointer; + c = get_symbol_name (&name); /* Get terminator. */ if (!ISALPHA (*name)) { - as_bad ("symbols assigned with .asg must begin with a letter"); + as_bad (_("symbols assigned with .asg must begin with a letter")); ignore_rest_of_line (); return; } - tmp = xmalloc (strlen (str) + 1); - strcpy (tmp, str); - str = tmp; - tmp = xmalloc (strlen (name) + 1); - strcpy (tmp, name); - name = tmp; + str = xstrdup (str); + name = xstrdup (name); subsym_create_or_replace (name, str); - *input_line_pointer = c; + (void) restore_line_pointer (c); demand_empty_rest_of_line (); } @@ -412,11 +406,9 @@ tic54x_eval (int x ATTRIBUTE_UNUSED) ignore_rest_of_line (); return; } - name = input_line_pointer; - c = get_symbol_end (); /* Get terminator. */ - tmp = xmalloc (strlen (name) + 1); - name = strcpy (tmp, name); - *input_line_pointer = c; + c = get_symbol_name (&name); /* Get terminator. */ + name = xstrdup (name); + (void) restore_line_pointer (c); if (!ISALPHA (*name)) { @@ -433,8 +425,7 @@ tic54x_eval (int x ATTRIBUTE_UNUSED) But since there's not written rule as to when, don't even bother trying to match their behavior. */ sprintf (valuestr, "%d", value); - tmp = xmalloc (strlen (valuestr) + 1); - strcpy (tmp, valuestr); + tmp = xstrdup (valuestr); subsym_create_or_replace (name, tmp); demand_empty_rest_of_line (); @@ -472,11 +463,12 @@ tic54x_bss (int x ATTRIBUTE_UNUSED) current_seg = now_seg; /* Save current seg. */ current_subseg = now_subseg; /* Save current subseg. */ - name = input_line_pointer; - c = get_symbol_end (); /* Get terminator. */ + c = get_symbol_name (&name); /* Get terminator. */ + if (c == '"') + c = * ++ input_line_pointer; if (c != ',') { - as_bad (".bss size argument missing\n"); + as_bad (_(".bss size argument missing\n")); ignore_rest_of_line (); return; } @@ -485,7 +477,7 @@ tic54x_bss (int x ATTRIBUTE_UNUSED) words = get_absolute_expression (); if (words < 0) { - as_bad (".bss size %d < 0!", words); + as_bad (_(".bss size %d < 0!"), words); ignore_rest_of_line (); return; } @@ -550,21 +542,16 @@ stag_add_field_symbols (struct stag *stag, symbolS *rootsym, const char *root_stag_name) { - char prefix[strlen (path) + 2]; + char * prefix; struct stag_field *field = stag->field; /* Construct a symbol for every field contained within this structure including fields within structure fields. */ - strcpy (prefix, path); - if (*path) - strcat (prefix, "."); + prefix = concat (path, *path ? "." : "", NULL); while (field != NULL) { - int len = strlen (prefix) + strlen (field->name) + 2; - char *name = xmalloc (len); - strcpy (name, prefix); - strcat (name, field->name); + char *name = concat (prefix, field->name, NULL); if (rootsym == NULL) { @@ -578,12 +565,10 @@ stag_add_field_symbols (struct stag *stag, } else { - char *replacement = xmalloc (strlen (name) - + strlen (stag->name) + 2); - strcpy (replacement, S_GET_NAME (rootsym)); - strcat (replacement, "+"); - strcat (replacement, root_stag_name); - strcat (replacement, name + strlen (S_GET_NAME (rootsym))); + char *replacement; + + replacement = concat (S_GET_NAME (rootsym), "+", root_stag_name, + name + strlen (S_GET_NAME (rootsym)), NULL); hash_insert (subsym_hash[0], name, replacement); } @@ -594,7 +579,9 @@ stag_add_field_symbols (struct stag *stag, field->offset, rootsym, root_stag_name); field = field->next; + free (name); } + free (prefix); } /* Keep track of stag fields so that when structures are nested we can add the @@ -609,7 +596,7 @@ stag_add_field (struct stag *parent, struct stag_field *sfield = xmalloc (sizeof (struct stag_field)); memset (sfield, 0, sizeof (*sfield)); - sfield->name = strcpy (xmalloc (strlen (name) + 1), name); + sfield->name = xstrdup (name); sfield->offset = offset; sfield->bitfield_offset = parent->current_bitfield_offset; sfield->stag = stag; @@ -696,11 +683,12 @@ tic54x_struct (int arg) } else { - char label[strlen (S_GET_NAME (line_label)) + 1]; - strcpy (label, S_GET_NAME (line_label)); - current_stag->sym = symbol_new (label, absolute_section, + char * label = xstrdup (S_GET_NAME (line_label)); + current_stag->sym = symbol_new (label, + absolute_section, (valueT) abs_section_offset, &zero_address_frag); + free (label); } current_stag->name = S_GET_NAME (current_stag->sym); SF_SET_LOCAL (current_stag->sym); @@ -783,8 +771,8 @@ tic54x_endstruct (int is_union) static void tic54x_tag (int ignore ATTRIBUTE_UNUSED) { - char *name = input_line_pointer; - int c = get_symbol_end (); + char *name; + int c = get_symbol_name (&name); struct stag *stag = (struct stag *) hash_find (stag_hash, name); if (!stag) @@ -804,9 +792,9 @@ tic54x_tag (int ignore ATTRIBUTE_UNUSED) } else { - char label[strlen (S_GET_NAME (line_label)) + 1]; + char * label; - strcpy (label, S_GET_NAME (line_label)); + label = xstrdup (S_GET_NAME (line_label)); if (current_stag != NULL) stag_add_field (current_stag, label, abs_section_offset - S_GET_VALUE (current_stag->sym), @@ -819,18 +807,20 @@ tic54x_tag (int ignore ATTRIBUTE_UNUSED) { as_bad (_(".tag target '%s' undefined"), label); ignore_rest_of_line (); + free (label); return; } stag_add_field_symbols (stag, S_GET_NAME (sym), S_GET_VALUE (stag->sym), sym, stag->name); } + free (label); } /* Bump by the struct size, but only if we're within a .struct section. */ if (current_stag != NULL && !current_stag->is_union) abs_section_offset += stag->size; - *input_line_pointer = c; + (void) restore_line_pointer (c); demand_empty_rest_of_line (); line_label = NULL; } @@ -934,12 +924,13 @@ tic54x_struct_field (int type) } else { - char label[strlen (S_GET_NAME (line_label) + 1)]; + char * label; - strcpy (label, S_GET_NAME (line_label)); + label = xstrdup (S_GET_NAME (line_label)); stag_add_field (current_stag, label, abs_section_offset - S_GET_VALUE (current_stag->sym), NULL); + free (label); } if (current_stag->is_union) @@ -1018,28 +1009,28 @@ tic54x_cons (int type) } else { - expressionS exp; + expressionS expn; - input_line_pointer = parse_expression (input_line_pointer, &exp); - if (exp.X_op == O_constant) + input_line_pointer = parse_expression (input_line_pointer, &expn); + if (expn.X_op == O_constant) { - offsetT value = exp.X_add_number; + offsetT value = expn.X_add_number; /* Truncate overflows. */ switch (octets) { case 1: if ((value > 0 && value > 0xFF) || (value < 0 && value < - 0x100)) - as_warn ("Overflow in expression, truncated to 8 bits"); + as_warn (_("Overflow in expression, truncated to 8 bits")); break; case 2: if ((value > 0 && value > 0xFFFF) || (value < 0 && value < - 0x10000)) - as_warn ("Overflow in expression, truncated to 16 bits"); + as_warn (_("Overflow in expression, truncated to 16 bits")); break; } } - if (exp.X_op != O_constant && octets < 2) + if (expn.X_op != O_constant && octets < 2) { /* Disallow .byte with a non constant expression that will require relocation. */ @@ -1048,7 +1039,7 @@ tic54x_cons (int type) return; } - if (exp.X_op != O_constant + if (expn.X_op != O_constant && amode == c_mode && octets == 4) { @@ -1059,14 +1050,14 @@ tic54x_cons (int type) totally ignored in the latest tools). */ amode = far_mode; emitting_long = 1; - emit_expr (&exp, 4); + emit_expr (&expn, 4); emitting_long = 0; amode = c_mode; } else { emitting_long = octets == 4; - emit_expr (&exp, (octets == 1) ? 2 : octets); + emit_expr (&expn, (octets == 1) ? 2 : octets); emitting_long = 0; } } @@ -1110,11 +1101,10 @@ tic54x_global (int type) do { - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); symbolP = symbol_find_or_make (name); + c = restore_line_pointer (c); - *input_line_pointer = c; S_SET_STORAGE_CLASS (symbolP, C_EXT); if (c == ',') { @@ -1185,13 +1175,14 @@ tic54x_sect (int arg) else { int c; - name = input_line_pointer; - c = get_symbol_end (); + + c = get_symbol_name (&name); len = strlen(name); name = strcpy (xmalloc (len + 10), name); - *input_line_pointer = c; + (void) restore_line_pointer (c); demand_empty_rest_of_line (); } + /* Make sure all named initialized sections flagged properly. If we encounter instructions, we'll flag it with SEC_CODE as well. */ strcat (name, ",\"w\"\n"); @@ -1222,7 +1213,7 @@ tic54x_sect (int arg) static void tic54x_space (int arg) { - expressionS exp; + expressionS expn; char *p = 0; int octets = 0; long words; @@ -1238,22 +1229,21 @@ tic54x_space (int arg) #endif /* Read the bit count. */ - expression (&exp); + expression (&expn); /* Some expressions are unresolvable until later in the assembly pass; postpone until relaxation/fixup. we also have to postpone if a previous partial allocation has not been completed yet. */ - if (exp.X_op != O_constant || frag_bit_offset (frag_now, now_seg) == -1) + if (expn.X_op != O_constant || frag_bit_offset (frag_now, now_seg) == -1) { struct bit_info *bi = xmalloc (sizeof (struct bit_info)); - char *p; bi->seg = now_seg; bi->type = bes; bi->sym = label; p = frag_var (rs_machine_dependent, 65536 * 2, 1, (relax_substateT) 0, - make_expr_symbol (&exp), (offsetT) 0, + make_expr_symbol (&expn), (offsetT) 0, (char *) bi); if (p) *p = 0; @@ -1268,7 +1258,7 @@ tic54x_space (int arg) { int spare_bits = bits_per_byte - bit_offset; - if (spare_bits >= exp.X_add_number) + if (spare_bits >= expn.X_add_number) { /* Don't have to do anything; sufficient bits have already been allocated; just point the label to the right place. */ @@ -1278,10 +1268,10 @@ tic54x_space (int arg) S_SET_VALUE (label, frag_now_fix () - 1); label = NULL; } - frag_now->tc_frag_data += exp.X_add_number; + frag_now->tc_frag_data += expn.X_add_number; goto getout; } - exp.X_add_number -= spare_bits; + expn.X_add_number -= spare_bits; /* Set the label to point to the first word allocated, which in this case is the previous word, which was only partially filled. */ if (!bes && label != NULL) @@ -1292,9 +1282,9 @@ tic54x_space (int arg) } } /* Convert bits to bytes/words and octets, rounding up. */ - words = ((exp.X_add_number + bits_per_byte - 1) / bits_per_byte); + words = ((expn.X_add_number + bits_per_byte - 1) / bits_per_byte); /* How many do we have left over? */ - bit_offset = exp.X_add_number % bits_per_byte; + bit_offset = expn.X_add_number % bits_per_byte; octets = words * OCTETS_PER_BYTE; if (octets < 0) { @@ -1368,17 +1358,13 @@ tic54x_usect (int x ATTRIBUTE_UNUSED) current_seg = now_seg; /* Save current seg. */ current_subseg = now_subseg; /* Save current subseg. */ - if (*input_line_pointer == '"') - input_line_pointer++; - section_name = input_line_pointer; - c = get_symbol_end (); /* Get terminator. */ - input_line_pointer++; /* Skip null symbol terminator. */ - name = xmalloc (input_line_pointer - section_name + 1); - strcpy (name, section_name); - - if (*input_line_pointer == ',') + c = get_symbol_name (§ion_name); /* Get terminator. */ + name = xstrdup (section_name); + c = restore_line_pointer (c); + + if (c == ',') ++input_line_pointer; - else if (c != ',') + else { as_bad (_("Missing size argument")); ignore_rest_of_line (); @@ -1439,7 +1425,7 @@ tic54x_usect (int x ATTRIBUTE_UNUSED) flags |= SEC_TIC54X_BLOCK; if (!bfd_set_section_flags (stdoutput, seg, flags)) - as_warn ("Error setting flags for \"%s\": %s", name, + as_warn (_("Error setting flags for \"%s\": %s"), name, bfd_errmsg (bfd_get_error ())); subseg_set (current_seg, current_subseg); /* Restore current seg. */ @@ -1571,7 +1557,6 @@ static void tic54x_stringer (int type) { unsigned int c; - char *start; int append_zero = type == 'S' || type == 'P'; int packed = type == 'p' || type == 'P'; int last_char = -1; /* Packed strings need two bytes at a time to encode. */ @@ -1601,7 +1586,6 @@ tic54x_stringer (int type) } case '\"': ++input_line_pointer; /* -> 1st char of string. */ - start = input_line_pointer; while (is_a_char (c = next_char_of_string ())) { if (!packed) @@ -1695,7 +1679,7 @@ tic54x_align_words (int arg) static void tic54x_field (int ignore ATTRIBUTE_UNUSED) { - expressionS exp; + expressionS expn; int size = 16; char *p; valueT value; @@ -1707,7 +1691,7 @@ tic54x_field (int ignore ATTRIBUTE_UNUSED) return; } - input_line_pointer = parse_expression (input_line_pointer, &exp); + input_line_pointer = parse_expression (input_line_pointer, &expn); if (*input_line_pointer == ',') { @@ -1722,7 +1706,7 @@ tic54x_field (int ignore ATTRIBUTE_UNUSED) } /* Truncate values to the field width. */ - if (exp.X_op != O_constant) + if (expn.X_op != O_constant) { /* If the expression value is relocatable, the field size *must* be 16. */ @@ -1734,17 +1718,17 @@ tic54x_field (int ignore ATTRIBUTE_UNUSED) } frag_now->tc_frag_data = 0; - emit_expr (&exp, 2); + emit_expr (&expn, 2); } else { unsigned long fmask = (size == 32) ? 0xFFFFFFFF : (1ul << size) - 1; - value = exp.X_add_number; - exp.X_add_number &= fmask; - if (value != (valueT) exp.X_add_number) + value = expn.X_add_number; + expn.X_add_number &= fmask; + if (value != (valueT) expn.X_add_number) as_warn (_("field value truncated")); - value = exp.X_add_number; + value = expn.X_add_number; /* Bits are stored MS first. */ while (size >= 16) { @@ -1844,8 +1828,7 @@ tic54x_clink (int ignored ATTRIBUTE_UNUSED) ; know (input_line_pointer[-1] == '\"'); input_line_pointer[-1] = 0; - name = xmalloc (input_line_pointer - section_name + 1); - strcpy (name, section_name); + name = xstrdup (section_name); seg = bfd_get_section_by_name (stdoutput, name); if (seg == NULL) @@ -1878,16 +1861,16 @@ tic54x_clink (int ignored ATTRIBUTE_UNUSED) static void tic54x_set_default_include (int dot) { - char *dir = "."; + const char *dir = "."; char *tmp = NULL; if (!dot) { - char *curfile; + const char *curfile; unsigned lineno; - as_where (&curfile, &lineno); - dir = strcpy (xmalloc (strlen (curfile) + 1), curfile); + curfile = as_where (&lineno); + dir = xstrdup (curfile); tmp = strrchr (dir, '/'); } if (tmp != NULL) @@ -1898,7 +1881,7 @@ tic54x_set_default_include (int dot) len = strlen (dir); if (include_dir_count == 0) { - include_dirs = (char **) xmalloc (sizeof (*include_dirs)); + include_dirs = XNEWVEC (const char *, 1); include_dir_count = 1; } include_dirs[0] = dir; @@ -1944,7 +1927,7 @@ tic54x_include (int ignored ATTRIBUTE_UNUSED) ++input_line_pointer; c = *input_line_pointer; *input_line_pointer = '\0'; - filename = strcpy (xmalloc (strlen (filename) + 1), filename); + filename = xstrdup (filename); *input_line_pointer = c; demand_empty_rest_of_line (); } @@ -1981,7 +1964,7 @@ tic54x_message (int type) ++input_line_pointer; c = *input_line_pointer; *input_line_pointer = 0; - msg = strcpy (xmalloc (strlen (msg) + 1), msg); + msg = xstrdup (msg); *input_line_pointer = c; } @@ -2012,17 +1995,17 @@ tic54x_message (int type) static void tic54x_label (int ignored ATTRIBUTE_UNUSED) { - char *name = input_line_pointer; + char *name; symbolS *symbolP; int c; ILLEGAL_WITHIN_STRUCT (); - c = get_symbol_end (); + c = get_symbol_name (&name); symbolP = colon (name); S_SET_STORAGE_CLASS (symbolP, C_STATLAB); - *input_line_pointer = c; + (void) restore_line_pointer (c); demand_empty_rest_of_line (); } @@ -2145,12 +2128,11 @@ tic54x_sblock (int ignore ATTRIBUTE_UNUSED) } else { - char *section_name = input_line_pointer; + char *section_name; - c = get_symbol_end (); - name = xmalloc (strlen (section_name) + 1); - strcpy (name, section_name); - *input_line_pointer = c; + c = get_symbol_name (§ion_name); + name = xstrdup (section_name); + (void) restore_line_pointer (c); } seg = bfd_get_section_by_name (stdoutput, name); @@ -2260,12 +2242,11 @@ tic54x_var (int ignore ATTRIBUTE_UNUSED) ignore_rest_of_line (); return; } - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); /* .var symbols start out with a null string. */ - name = strcpy (xmalloc (strlen (name) + 1), name); + name = xstrdup (name); hash_insert (subsym_hash[macro_level], name, empty); - *input_line_pointer = c; + c = restore_line_pointer (c); if (c == ',') { ++input_line_pointer; @@ -2372,13 +2353,13 @@ tic54x_mlib (int ignore ATTRIBUTE_UNUSED) FILE *ftmp; /* We're not sure how big it is, but it will be smaller than "size". */ - bfd_bread (buf, size, mbfd); + size = bfd_bread (buf, size, mbfd); /* Write to a temporary file, then use s_include to include it a bit of a hack. */ ftmp = fopen (fname, "w+b"); fwrite ((void *) buf, size, 1, ftmp); - if (buf[size - 1] != '\n') + if (size == 0 || buf[size - 1] != '\n') fwrite ("\n", 1, 1, ftmp); fclose (ftmp); free (buf); @@ -2475,7 +2456,7 @@ const pseudo_typeS md_pseudo_table[] = }; int -md_parse_option (int c, char *arg) +md_parse_option (int c, const char *arg) { switch (c) { @@ -2504,7 +2485,7 @@ md_parse_option (int c, char *arg) break; case OPTION_STDERR_TO_FILE: { - char *filename = arg; + const char *filename = arg; FILE *fp = fopen (filename, "w+"); if (fp == NULL) @@ -2631,8 +2612,7 @@ subsym_ismember (char *sym, char *list) return 0; } - ptr = elem = xmalloc (strlen (listv) + 1); - strcpy (elem, listv); + ptr = elem = xstrdup (listv); while (*ptr && *ptr != ',') ++ptr; *ptr++ = 0; @@ -2656,11 +2636,11 @@ subsym_ismember (char *sym, char *list) static int subsym_iscons (char *a, char *ignore ATTRIBUTE_UNUSED) { - expressionS exp; + expressionS expn; - parse_expression (a, &exp); + parse_expression (a, &expn); - if (exp.X_op == O_constant) + if (expn.X_op == O_constant) { int len = strlen (a); @@ -2920,7 +2900,7 @@ math_tanh (float arg1, float ignore ATTRIBUTE_UNUSED) /* Built-in substitution symbol functions and math functions. */ typedef struct { - char *name; + const char *name; int (*proc) (char *, char *); int nargs; } subsym_proc_entry; @@ -2944,7 +2924,7 @@ static const subsym_proc_entry subsym_procs[] = typedef struct { - char *name; + const char *name; float (*proc) (float, float); int nargs; int int_return; @@ -2989,7 +2969,7 @@ static const math_proc_entry math_procs[] = void md_begin (void) { - template *tm; + insn_template *tm; symbol *sym; const subsym_proc_entry *subsym_proc; const math_proc_entry *math_proc; @@ -3018,7 +2998,7 @@ md_begin (void) } op_hash = hash_new (); - for (tm = (template *) tic54x_optab; tm->name; tm++) + for (tm = (insn_template *) tic54x_optab; tm->name; tm++) { if (hash_find (op_hash, tm->name)) continue; @@ -3028,7 +3008,7 @@ md_begin (void) tm->name, hash_err); } parop_hash = hash_new (); - for (tm = (template *) tic54x_paroptab; tm->name; tm++) + for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++) { if (hash_find (parop_hash, tm->name)) continue; @@ -3128,7 +3108,7 @@ get_operands (struct opstruct operands[], char *line) { if (paren_not_balanced) { - as_bad ("Unbalanced parenthesis in operand %d", numexp); + as_bad (_("Unbalanced parenthesis in operand %d"), numexp); return -1; } else @@ -3159,7 +3139,7 @@ get_operands (struct opstruct operands[], char *line) { if (expecting_operand || *lptr == ',') { - as_bad ("Expecting operand after ','"); + as_bad (_("Expecting operand after ','")); return -1; } } @@ -3167,7 +3147,7 @@ get_operands (struct opstruct operands[], char *line) { if (*++lptr == '\0') { - as_bad ("Expecting operand after ','"); + as_bad (_("Expecting operand after ','")); return -1; } expecting_operand = 1; @@ -3178,7 +3158,7 @@ get_operands (struct opstruct operands[], char *line) ; if (!is_end_of_line[(int) *lptr]) { - as_bad ("Extra junk on line"); + as_bad (_("Extra junk on line")); return -1; } @@ -4179,7 +4159,7 @@ optimize_insn (tic54x_insn *insn) static int tic54x_parse_insn (tic54x_insn *insn, char *line) { - insn->tm = (template *) hash_find (op_hash, insn->mnemonic); + insn->tm = (insn_template *) hash_find (op_hash, insn->mnemonic); if (!insn->tm) { as_bad (_("Unrecognized instruction \"%s\""), insn->mnemonic); @@ -4202,8 +4182,8 @@ tic54x_parse_insn (tic54x_insn *insn, char *line) /* SUCCESS! now try some optimizations. */ if (optimize_insn (insn)) { - insn->tm = (template *) hash_find (op_hash, - insn->mnemonic); + insn->tm = (insn_template *) hash_find (op_hash, + insn->mnemonic); continue; } @@ -4237,7 +4217,7 @@ next_line_shows_parallel (char *next_line) static int tic54x_parse_parallel_insn_firstline (tic54x_insn *insn, char *line) { - insn->tm = (template *) hash_find (parop_hash, insn->mnemonic); + insn->tm = (insn_template *) hash_find (parop_hash, insn->mnemonic); if (!insn->tm) { as_bad (_("Unrecognized parallel instruction \"%s\""), @@ -4304,7 +4284,7 @@ tic54x_parse_parallel_insn_lastline (tic54x_insn *insn, char *line) replacement on the value. */ static char * -subsym_get_arg (char *line, char *terminators, char **str, int nosub) +subsym_get_arg (char *line, const char *terminators, char **str, int nosub) { char *ptr = line; char *endp; @@ -4336,7 +4316,7 @@ subsym_get_arg (char *line, char *terminators, char **str, int nosub) } else { - char *term = terminators; + const char *term = terminators; char *value = NULL; while (*ptr && *ptr != *term) @@ -4425,8 +4405,7 @@ subsym_substitute (char *line, int forced) char *tmp; /* Work with a copy of the input line. */ - replacement = xmalloc (strlen (line) + 1); - strcpy (replacement, line); + replacement = xstrdup (line); ptr = head = replacement; @@ -4504,8 +4483,8 @@ subsym_substitute (char *line, int forced) if (forced) ++ptr; - name = input_line_pointer = ptr; - c = get_symbol_end (); + input_line_pointer = ptr; + c = get_symbol_name (&name); /* '?' is not normally part of a symbol, but it IS part of a local label. */ if (c == '?') @@ -4536,7 +4515,7 @@ subsym_substitute (char *line, int forced) if (value == NULL) { char digit[11]; - char *namecopy = strcpy (xmalloc (strlen (name) + 1), name); + char *namecopy = xstrdup (name); value = strcpy (xmalloc (strlen (name) + sizeof (digit) + 1), name); @@ -4570,10 +4549,10 @@ subsym_substitute (char *line, int forced) ++ptr; if (math_entry != NULL) { - float arg1, arg2 = 0; + float farg1, farg2 = 0; volatile float fresult; - arg1 = (float) strtod (ptr, &ptr); + farg1 = (float) strtod (ptr, &ptr); if (math_entry->nargs == 2) { if (*ptr++ != ',') @@ -4581,9 +4560,9 @@ subsym_substitute (char *line, int forced) as_bad (_("Expecting second argument")); break; } - arg2 = (float) strtod (ptr, &ptr); + farg2 = (float) strtod (ptr, &ptr); } - fresult = (*math_entry->proc) (arg1, arg2); + fresult = (*math_entry->proc) (farg1, farg2); value = xmalloc (128); if (math_entry->int_return) sprintf (value, "%d", (int) fresult); @@ -4661,7 +4640,7 @@ subsym_substitute (char *line, int forced) substitutions are performed, or a substitution that has been previously made is encountered again. - put the symbol into the recursion hash table so we only + Put the symbol into the recursion hash table so we only try to replace a symbol once. */ if (recurse) { @@ -4681,8 +4660,7 @@ subsym_substitute (char *line, int forced) kinda indicates that forced substitution is not supposed to be recursive, but I'm not sure. */ unsigned beg, len = 1; /* default to a single char */ - char *newval = strcpy (xmalloc (strlen (value) + 1), - value); + char *newval = xstrdup (value); savedp = input_line_pointer; input_line_pointer = tail + 1; @@ -4781,7 +4759,7 @@ tic54x_start_line_hook (void) line[endp - input_line_pointer] = 0; /* Scan ahead for parallel insns. */ - parallel_on_next_line_hint = next_line_shows_parallel (endp + 1); + parallel_on_next_line_hint = next_line_shows_parallel (endp); /* If within a macro, first process forced replacements. */ if (macro_level > 0) @@ -4850,7 +4828,7 @@ md_assemble (char *line) int c; input_line_pointer = line; - c = get_symbol_end (); + c = get_symbol_name (&line); if (cpu == VNONE) cpu = V542; @@ -5010,9 +4988,8 @@ tic54x_adjust_symtab (void) if (symbol_rootP == NULL || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE) { - char *filename; unsigned lineno; - as_where (&filename, &lineno); + const char * filename = as_where (&lineno); c_dot_file_symbol (filename, 0); } } @@ -5080,7 +5057,7 @@ tic54x_undefined_symbol (char *name) int tic54x_parse_name (char *name ATTRIBUTE_UNUSED, - expressionS *exp ATTRIBUTE_UNUSED) + expressionS *expn ATTRIBUTE_UNUSED) { return 0; } @@ -5125,10 +5102,9 @@ tc_gen_reloc (asection *section, fixS *fixP) /* Handle cons expressions. */ void -tic54x_cons_fix_new (fragS *frag, int where, int octets, expressionS *exp) +tic54x_cons_fix_new (fragS *frag, int where, int octets, expressionS *expn, + bfd_reloc_code_real_type r) { - bfd_reloc_code_real_type r; - switch (octets) { default: @@ -5148,7 +5124,7 @@ tic54x_cons_fix_new (fragS *frag, int where, int octets, expressionS *exp) r = BFD_RELOC_32; break; } - fix_new_exp (frag, where, octets, exp, 0, r); + fix_new_exp (frag, where, octets, expn, 0, r); } /* Attempt to simplify or even eliminate a fixup. @@ -5366,22 +5342,21 @@ tic54x_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, syntax puts the symbol *before* the pseudo (which is kinda like MRI syntax, I guess, except I've never seen a definition of MRI syntax). - C is the character that used to be at *REST, which points to the end of the - label. - Don't allow labels to start with '.' */ int -tic54x_start_label (int c, char *rest) +tic54x_start_label (int nul_char, int next_char) { + char *rest; + /* If within .struct/.union, no auto line labels, please. */ if (current_stag != NULL) return 0; /* Disallow labels starting with "." */ - if (c != ':') + if (next_char != ':') { - char *label = rest; + char *label = input_line_pointer; while (!is_end_of_line[(int) label[-1]]) --label; @@ -5392,22 +5367,22 @@ tic54x_start_label (int c, char *rest) } } - if (is_end_of_line[(int) c]) + if (is_end_of_line[(int) next_char]) return 1; - if (ISSPACE (c)) - while (ISSPACE (c = *++rest)) - ; - if (c == '.') - { - /* Don't let colon () define a label for any of these... */ - return (strncasecmp (rest, ".tag", 4) != 0 || !ISSPACE (rest[4])) - && (strncasecmp (rest, ".struct", 7) != 0 || !ISSPACE (rest[7])) - && (strncasecmp (rest, ".union", 6) != 0 || !ISSPACE (rest[6])) - && (strncasecmp (rest, ".macro", 6) != 0 || !ISSPACE (rest[6])) - && (strncasecmp (rest, ".set", 4) != 0 || !ISSPACE (rest[4])) - && (strncasecmp (rest, ".equ", 4) != 0 || !ISSPACE (rest[4])); - } + rest = input_line_pointer; + if (nul_char == '"') + ++rest; + while (ISSPACE (next_char)) + next_char = *++rest; + if (next_char != '.') + return 1; - return 1; + /* Don't let colon () define a label for any of these... */ + return ((strncasecmp (rest, ".tag", 4) != 0 || !ISSPACE (rest[4])) + && (strncasecmp (rest, ".struct", 7) != 0 || !ISSPACE (rest[7])) + && (strncasecmp (rest, ".union", 6) != 0 || !ISSPACE (rest[6])) + && (strncasecmp (rest, ".macro", 6) != 0 || !ISSPACE (rest[6])) + && (strncasecmp (rest, ".set", 4) != 0 || !ISSPACE (rest[4])) + && (strncasecmp (rest, ".equ", 4) != 0 || !ISSPACE (rest[4]))); }