X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fconfig%2Ftc-mips.c;h=db3ec6775e2a3b3913c58fe5817bb95cb81beca7;hb=b99747aeed79ad69af8b8be4d9aa3a74200fca7d;hp=859ddc6a79a09ea517cf4370b2e148810d66ce98;hpb=6f2750feaf2827ef8a1a0a5b2f90c1e9a6cabbd1;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 859ddc6a79..db3ec6775e 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -1307,7 +1307,7 @@ static void mips16_macro (struct mips_cl_insn * ip); static void mips_ip (char *str, struct mips_cl_insn * ip); static void mips16_ip (char *str, struct mips_cl_insn * ip); static void mips16_immed - (char *, unsigned int, int, bfd_reloc_code_real_type, offsetT, + (const char *, unsigned int, int, bfd_reloc_code_real_type, offsetT, unsigned int, unsigned long *); static size_t my_getSmallExpression (expressionS *, bfd_reloc_code_real_type *, char *); @@ -2089,10 +2089,8 @@ mips_lookup_ase (const char *name) } /* Return the length of a microMIPS instruction in bytes. If bits of - the mask beyond the low 16 are 0, then it is a 16-bit instruction. - Otherwise assume a 32-bit instruction; 48-bit instructions (0x1f - major opcode) will require further modifications to the opcode - table. */ + the mask beyond the low 16 are 0, then it is a 16-bit instruction, + otherwise it is a 32-bit instruction. */ static inline unsigned int micromips_insn_length (const struct mips_opcode *mo) @@ -2422,9 +2420,8 @@ set_insn_error_ss (int argnum, const char *msg, const char *s1, const char *s2) static void report_insn_error (const char *str) { - const char *msg; + const char *msg = concat (insn_error.msg, " `%s'", NULL); - msg = ACONCAT ((insn_error.msg, " `%s'", NULL)); switch (insn_error.format) { case ERR_FMT_PLAIN: @@ -2439,6 +2436,8 @@ report_insn_error (const char *str) as_bad (msg, insn_error.u.ss[0], insn_error.u.ss[1], str); break; } + + free ((char *) msg); } /* Initialize vr4120_conflicts. There is a bit of duplication here: @@ -3043,7 +3042,8 @@ mips_parse_base_start (char *s) static char * mips_parse_argument_token (char *s, char float_format) { - char *end, *save_in, *err; + char *end, *save_in; + const char *err; unsigned int regno1, regno2, channels; struct mips_operand_token token; @@ -3466,6 +3466,12 @@ md_begin (void) as_bad (_("-G may not be used in position-independent code")); g_switch_value = 0; } + else if (mips_abicalls) + { + if (g_switch_seen && g_switch_value != 0) + as_bad (_("-G may not be used with abicalls")); + g_switch_value = 0; + } if (! bfd_set_arch_mach (stdoutput, bfd_arch_mips, file_mips_opts.arch)) as_warn (_("could not set architecture and machine")); @@ -3844,7 +3850,7 @@ mips_check_options (struct mips_set_options *opts, bfd_boolean abi_checks) if (abi_checks && ABI_NEEDS_64BIT_REGS (mips_abi)) as_warn (_("`fp=32' used with a 64-bit ABI")); - if (ISA_IS_R6 (mips_opts.isa) && opts->single_float == 0) + if (ISA_IS_R6 (opts->isa) && opts->single_float == 0) as_bad (_("`fp=32' used with a MIPS R6 cpu")); break; default: @@ -3856,13 +3862,13 @@ mips_check_options (struct mips_set_options *opts, bfd_boolean abi_checks) as_bad (_("`nooddspreg` cannot be used with a 64-bit ABI")); if (opts->micromips == 1 && opts->mips16 == 1) - as_bad (_("`mips16' cannot be used with `micromips'")); - else if (ISA_IS_R6 (mips_opts.isa) + as_bad (_("`%s' cannot be used with `%s'"), "mips16", "micromips"); + else if (ISA_IS_R6 (opts->isa) && (opts->micromips == 1 || opts->mips16 == 1)) - as_fatal (_("`%s' can not be used with `%s'"), + as_fatal (_("`%s' cannot be used with `%s'"), opts->micromips ? "micromips" : "mips16", - mips_cpu_info_from_isa (mips_opts.isa)->name); + mips_cpu_info_from_isa (opts->isa)->name); if (ISA_IS_R6 (opts->isa) && mips_relax_branch) as_fatal (_("branch relaxation is not supported in `%s'"), @@ -6727,11 +6733,11 @@ can_swap_branch_p (struct mips_cl_insn *ip, expressionS *address_expr, /* Parameter must be 16 bit. */ && (*reloc_type == BFD_RELOC_16_PCREL_S2) /* Branch to same segment. */ - && (S_GET_SEGMENT(address_expr->X_add_symbol) == now_seg) + && (S_GET_SEGMENT (address_expr->X_add_symbol) == now_seg) /* Branch to same code fragment. */ - && (symbol_get_frag(address_expr->X_add_symbol) == frag_now) + && (symbol_get_frag (address_expr->X_add_symbol) == frag_now) /* Can only calculate branch offset if value is known. */ - && symbol_constant_p(address_expr->X_add_symbol) + && symbol_constant_p (address_expr->X_add_symbol) /* Check if branch is really conditional. */ && !((ip->insn_opcode & 0xffff0000) == 0x10000000 /* beq $0,$0 */ || (ip->insn_opcode & 0xffff0000) == 0x04010000 /* bgez $0 */ @@ -6740,7 +6746,7 @@ can_swap_branch_p (struct mips_cl_insn *ip, expressionS *address_expr, int distance; /* Check if loop is shorter than 6 instructions including branch and delay slot. */ - distance = frag_now_fix() - S_GET_VALUE(address_expr->X_add_symbol); + distance = frag_now_fix () - S_GET_VALUE (address_expr->X_add_symbol); if (distance <= 20) { int i; @@ -6752,7 +6758,7 @@ can_swap_branch_p (struct mips_cl_insn *ip, expressionS *address_expr, for (i = 0; i < (distance / 4); i++) { if ((history[i].cleared_p) - || delayed_branch_p(&history[i])) + || delayed_branch_p (&history[i])) { rv = TRUE; break; @@ -7408,8 +7414,7 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr, if (hi_fixup == 0 || !fixup_has_matching_lo_p (hi_fixup->fixp)) { - hi_fixup = ((struct mips_hi_fixup *) - xmalloc (sizeof (struct mips_hi_fixup))); + hi_fixup = XNEW (struct mips_hi_fixup); hi_fixup->next = mips_hi_fixup_list; mips_hi_fixup_list = hi_fixup; } @@ -12689,8 +12694,8 @@ macro (struct mips_cl_insn *ip, char *str) case M_DROL_I: { unsigned int rot; - char *l; - char *rr; + const char *l; + const char *rr; rot = imm_expr.X_add_number & 0x3f; if (ISA_HAS_DROR (mips_opts.isa) || CPU_HAS_DROR (mips_opts.arch)) @@ -12769,8 +12774,8 @@ macro (struct mips_cl_insn *ip, char *str) case M_DROR_I: { unsigned int rot; - char *l; - char *rr; + const char *l; + const char *rr; rot = imm_expr.X_add_number & 0x3f; if (ISA_HAS_DROR (mips_opts.isa) || CPU_HAS_DROR (mips_opts.arch)) @@ -13526,14 +13531,12 @@ mips_lookup_insn (struct hash_control *hash, const char *start, struct mips_opcode *insn; /* Make a copy of the instruction so that we can fiddle with it. */ - name = alloca (length + 1); - memcpy (name, start, length); - name[length] = '\0'; + name = xstrndup (start, length); /* Look up the instruction as-is. */ insn = (struct mips_opcode *) hash_find (hash, name); if (insn) - return insn; + goto end; dot = strchr (name, '.'); if (dot && dot[1]) @@ -13548,7 +13551,7 @@ mips_lookup_insn (struct hash_control *hash, const char *start, if (insn && (insn->pinfo2 & INSN2_VU0_CHANNEL_SUFFIX) != 0) { *opcode_extra |= mask << mips_vu0_channel_mask.lsb; - return insn; + goto end; } } } @@ -13573,12 +13576,15 @@ mips_lookup_insn (struct hash_control *hash, const char *start, if (insn) { forced_insn_length = suffix; - return insn; + goto end; } } } - return NULL; + insn = NULL; + end: + free (name); + return insn; } /* Assemble an instruction into its binary format. If the instruction @@ -13780,7 +13786,7 @@ mips16_immed_in_range_p (const struct mips_int_operand *operand, is the length that the user requested, or 0 if none. */ static void -mips16_immed (char *file, unsigned int line, int type, +mips16_immed (const char *file, unsigned int line, int type, bfd_reloc_code_real_type reloc, offsetT val, unsigned int user_insn_length, unsigned long *insn) { @@ -13990,7 +13996,7 @@ my_getExpression (expressionS *ep, char *str) input_line_pointer = save_in; } -char * +const char * md_atof (int type, char *litP, int *sizeP) { return ieee_md_atof (type, litP, sizeP, target_big_endian); @@ -14038,7 +14044,7 @@ mips_set_option_string (const char **string_ptr, const char *new_value) } int -md_parse_option (int c, char *arg) +md_parse_option (int c, const char *arg) { unsigned int i; @@ -15466,20 +15472,22 @@ s_option (int x ATTRIBUTE_UNUSED) { /* FIXME: What does this mean? */ } - else if (strncmp (opt, "pic", 3) == 0) + else if (strncmp (opt, "pic", 3) == 0 && ISDIGIT (opt[3]) && opt[4] == '\0') { int i; i = atoi (opt + 3); - if (i == 0) + if (i != 0 && i != 2) + as_bad (_(".option pic%d not supported"), i); + else if (mips_pic == VXWORKS_PIC) + as_bad (_(".option pic%d not supported in VxWorks PIC mode"), i); + else if (i == 0) mips_pic = NO_PIC; else if (i == 2) { mips_pic = SVR4_PIC; mips_abicalls = TRUE; } - else - as_bad (_(".option pic%d not supported"), i); if (mips_pic == SVR4_PIC) { @@ -15674,7 +15682,7 @@ s_mipsset (int x ATTRIBUTE_UNUSED) { struct mips_option_stack *s; - s = (struct mips_option_stack *) xmalloc (sizeof *s); + s = XNEW (struct mips_option_stack); s->next = mips_opts_stack; s->options = mips_opts; mips_opts_stack = s; @@ -17163,8 +17171,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) bfd_reloc_code_real_type code; memset (retval, 0, sizeof(retval)); - reloc = retval[0] = (arelent *) xcalloc (1, sizeof (arelent)); - reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + reloc = retval[0] = XCNEW (arelent); + reloc->sym_ptr_ptr = XNEW (asymbol *); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; @@ -17881,7 +17889,7 @@ mips_record_label (symbolS *sym) struct insn_label_list *l; if (free_insn_labels == NULL) - l = (struct insn_label_list *) xmalloc (sizeof *l); + l = XNEW (struct insn_label_list); else { l = free_insn_labels; @@ -18362,7 +18370,7 @@ s_mips_end (int x ATTRIBUTE_UNUSED) if (p && cur_proc_ptr) { OBJ_SYMFIELD_TYPE *obj = symbol_get_obj (p); - expressionS *exp = xmalloc (sizeof (expressionS)); + expressionS *exp = XNEW (expressionS); obj->size = exp; exp->X_op = O_subtract;