diff options
Diffstat (limited to 'gas/config/tc-v850.c')
-rw-r--r-- | gas/config/tc-v850.c | 142 |
1 files changed, 57 insertions, 85 deletions
diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c index 0a48343..176910d 100644 --- a/gas/config/tc-v850.c +++ b/gas/config/tc-v850.c @@ -247,8 +247,7 @@ v850_offset (int ignore ATTRIBUTE_UNUSED) char *pfrag; int temp = get_absolute_expression (); - pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, (symbolS *)0, - (offsetT) temp, (char *) 0); + pfrag = frag_var (rs_org, 1, 1, 0, NULL, temp, NULL); *pfrag = 0; demand_empty_rest_of_line (); @@ -345,15 +344,10 @@ v850_comm (int area) int old_subsec; char *pfrag; int align; - flagword applicable; old_sec = now_seg; old_subsec = now_subseg; - applicable = bfd_applicable_section_flags (stdoutput); - - applicable &= SEC_ALLOC; - switch (area) { case SCOMMON_SECTION: @@ -412,8 +406,7 @@ v850_comm (int area) } symbol_set_frag (symbolP, frag_now); - pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, - (offsetT) size, (char *) 0); + pfrag = frag_var (rs_org, 1, 1, 0, symbolP, size, NULL); *pfrag = 0; S_SET_SIZE (symbolP, size); @@ -1675,42 +1668,29 @@ md_atof (int type, char *litp, int *sizep) void md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, - asection *sec, + asection *sec ATTRIBUTE_UNUSED, fragS *fragP) { - union u - { - bfd_reloc_code_real_type fx_r_type; - char * fr_opcode; - } - opcode_converter; - subseg_change (sec, 0); - - opcode_converter.fr_opcode = fragP->fr_opcode; - - subseg_change (sec, 0); + unsigned int opindex = (uintptr_t) fragP->fr_opcode; if (fragP->fr_subtype == SUBYPTE_LOOP_16_22) { fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, - fragP->fr_offset, 1, - BFD_RELOC_UNUSED + opcode_converter.fx_r_type); + fragP->fr_offset, 1, BFD_RELOC_UNUSED + opindex); fragP->fr_fix += 4; } else if (fragP->fr_subtype == SUBYPTE_LOOP_16_22 + 1) { - unsigned char * buffer = - (unsigned char *) (fragP->fr_fix + &fragP->fr_literal[0]); - int loop_reg = (buffer[0] & 0x1f); + char *buffer = fragP->fr_literal + fragP->fr_fix; + int loop_reg = buffer[0] & 0x1f; /* Add -1.reg. */ - md_number_to_chars ((char *) buffer, 0x025f | (loop_reg << 11), 2); + md_number_to_chars (buffer, 0x025f | (loop_reg << 11), 2); /* Now create the conditional branch + fixup to the final target. */ /* 0x000107ea = bne LBL(disp17). */ - md_number_to_chars ((char *) buffer + 2, 0x000107ea, 4); + md_number_to_chars (buffer + 2, 0x000107ea, 4); fix_new (fragP, fragP->fr_fix + 2, 4, fragP->fr_symbol, - fragP->fr_offset, 1, - BFD_RELOC_V850_17_PCREL); + fragP->fr_offset, 1, BFD_RELOC_V850_17_PCREL); fragP->fr_fix += 6; } /* In range conditional or unconditional branch. */ @@ -1727,8 +1707,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, { fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, - fragP->fr_offset, 1, - BFD_RELOC_UNUSED + opcode_converter.fx_r_type); + fragP->fr_offset, 1, BFD_RELOC_UNUSED + opindex); fragP->fr_fix += 2; } /* V850e2r-v3 17bit conditional branch. */ @@ -1737,8 +1716,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, || fragP->fr_subtype == SUBYPTE_SA_9_17_22 + 1 || fragP->fr_subtype == SUBYPTE_SA_9_17_22_32 + 1) { - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + &fragP->fr_literal[0]); + char *buffer = fragP->fr_literal + fragP->fr_fix; buffer[0] &= 0x0f; /* Use condition. */ buffer[0] |= 0xe0; @@ -1746,7 +1724,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, /* Now create the unconditional branch + fixup to the final target. */ - md_number_to_chars ((char *) buffer + 2, 0x0001, 2); + md_number_to_chars (buffer + 2, 0x0001, 2); fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 1, BFD_RELOC_V850_17_PCREL); fragP->fr_fix += 4; @@ -1757,8 +1735,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, || fragP->fr_subtype == SUBYPTE_COND_9_17_22 + 2 || fragP->fr_subtype == SUBYPTE_COND_9_17_22_32 + 2) { - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + fragP->fr_literal); + char *buffer = fragP->fr_literal + fragP->fr_fix; /* Reverse the condition of the first branch. */ buffer[0] ^= 0x08; @@ -1771,7 +1748,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, /* Now create the unconditional branch + fixup to the final target. */ - md_number_to_chars ((char *) buffer + 2, 0x00000780, 4); + md_number_to_chars (buffer + 2, 0x00000780, 4); fix_new (fragP, fragP->fr_fix + 2, 4, fragP->fr_symbol, fragP->fr_offset, 1, BFD_RELOC_V850_22_PCREL); fragP->fr_fix += 6; @@ -1780,8 +1757,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, else if (fragP->fr_subtype == SUBYPTE_COND_9_22_32 + 2 || fragP->fr_subtype == SUBYPTE_COND_9_17_22_32 + 3) { - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + fragP->fr_literal); + char *buffer = fragP->fr_literal + fragP->fr_fix; /* Reverse the condition of the first branch. */ buffer[0] ^= 0x08; @@ -1794,7 +1770,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, /* Now create the unconditional branch + fixup to the final target. */ - md_number_to_chars ((char *) buffer + 2, 0x02e0, 2); + md_number_to_chars (buffer + 2, 0x02e0, 2); fix_new (fragP, fragP->fr_fix + 4, 4, fragP->fr_symbol, fragP->fr_offset + 2, 1, BFD_RELOC_V850_32_PCREL); fragP->fr_fix += 8; @@ -1822,8 +1798,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, || fragP->fr_subtype == SUBYPTE_SA_9_17_22 + 2 || fragP->fr_subtype == SUBYPTE_SA_9_17_22_32 + 2) { - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + fragP->fr_literal); + char *buffer = fragP->fr_literal + fragP->fr_fix; /* bsa .+4 */ buffer[0] &= 0x8f; @@ -1831,23 +1806,21 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, buffer[1] &= 0x07; /* br .+6 */ - md_number_to_chars ((char *) buffer + 2, 0x05b5, 2); + md_number_to_chars (buffer + 2, 0x05b5, 2); /* Now create the unconditional branch + fixup to the final target. */ /* jr SYM */ - md_number_to_chars ((char *) buffer + 4, 0x00000780, 4); + md_number_to_chars (buffer + 4, 0x00000780, 4); fix_new (fragP, fragP->fr_fix + 4, 4, fragP->fr_symbol, - fragP->fr_offset, 1, - BFD_RELOC_V850_22_PCREL); + fragP->fr_offset, 1, BFD_RELOC_V850_22_PCREL); fragP->fr_fix += 8; } /* Out of range SA conditional branch. Emit a branch around a 32bit jump. */ else if (fragP->fr_subtype == SUBYPTE_SA_9_22_32 + 2 || fragP->fr_subtype == SUBYPTE_SA_9_17_22_32 + 3) { - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + fragP->fr_literal); + char *buffer = fragP->fr_literal + fragP->fr_fix; /* bsa .+2 */ buffer[0] &= 0x8f; @@ -1855,12 +1828,12 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, buffer[1] &= 0x07; /* br .+8 */ - md_number_to_chars ((char *) buffer + 2, 0x05c5, 2); + md_number_to_chars (buffer + 2, 0x05c5, 2); /* Now create the unconditional branch + fixup to the final target. */ /* jr SYM */ - md_number_to_chars ((char *) buffer + 4, 0x02e0, 2); + md_number_to_chars (buffer + 4, 0x02e0, 2); fix_new (fragP, fragP->fr_fix + 6, 4, fragP->fr_symbol, fragP->fr_offset + 2, 1, BFD_RELOC_V850_32_PCREL); @@ -1958,7 +1931,7 @@ md_begin (void) { if (strcmp (prev_name, op->name)) { - prev_name = (char *) op->name; + prev_name = op->name; str_hash_insert (v850_hash, op->name, op, 0); } op++; @@ -2312,7 +2285,7 @@ md_assemble (char *str) *s++ = '\0'; /* Find the first opcode with the proper name. */ - opcode = (struct v850_opcode *) str_hash_find (v850_hash, str); + opcode = str_hash_find (v850_hash, str); if (opcode == NULL) { /* xgettext:c-format */ @@ -3070,7 +3043,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 6, 2, SUBYPTE_LOOP_16_22, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f+4, 0, 4); } @@ -3087,7 +3060,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 4, 2, SUBYPTE_UNCOND_9_22, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 2); } @@ -3096,7 +3069,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 6, 4, SUBYPTE_UNCOND_9_22_32, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 4); } @@ -3113,7 +3086,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 8, 6, SUBYPTE_SA_9_17_22, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 6); } @@ -3122,7 +3095,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 6, 4, SUBYPTE_COND_9_17_22, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 4); } @@ -3134,7 +3107,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 8, 6, SUBYPTE_SA_9_22, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 6); } @@ -3143,7 +3116,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 6, 4, SUBYPTE_COND_9_22, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 4); } @@ -3158,7 +3131,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 10, 8, SUBYPTE_SA_9_17_22_32, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 8); } @@ -3167,7 +3140,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 8, 6, SUBYPTE_COND_9_17_22_32, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 6); } @@ -3179,7 +3152,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 10, 8, SUBYPTE_SA_9_22_32, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 8); } @@ -3188,7 +3161,7 @@ md_assemble (char *str) f = frag_var (rs_machine_dependent, 8, 6, SUBYPTE_COND_9_22_32, fixups[0].exp.X_add_symbol, fixups[0].exp.X_add_number, - (char *)(size_t) fixups[0].opindex); + (char *) (uintptr_t) fixups[0].opindex); md_number_to_chars (f, insn, insn_size); md_number_to_chars (f + 2, 0, 6); } @@ -3312,8 +3285,7 @@ md_assemble (char *str) f - frag_now->fr_literal, 4, & fixups[i].exp, (operand->flags & V850_PCREL) != 0, - (bfd_reloc_code_real_type) (fixups[i].opindex - + (int) BFD_RELOC_UNUSED)); + fixups[i].opindex + BFD_RELOC_UNUSED); } } @@ -3396,7 +3368,7 @@ v850_pcrel_from_section (fixS *fixp, segT section) /* If the symbol is undefined, or in a section other than our own, or it is weak (in which case it may well be in another section, then let the linker figure it out. */ - if (fixp->fx_addsy != (symbolS *) NULL + if (fixp->fx_addsy != NULL && (! S_IS_DEFINED (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy) || (S_GET_SEGMENT (fixp->fx_addsy) != section))) @@ -3420,7 +3392,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) return; } - if (fixP->fx_addsy == (symbolS *) NULL) + if (fixP->fx_addsy == NULL) fixP->fx_addnumber = value, fixP->fx_done = 1; @@ -3430,7 +3402,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) else { value = fixP->fx_offset; - if (fixP->fx_subsy != (symbolS *) NULL) + if (fixP->fx_subsy != NULL) { if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section) value -= S_GET_VALUE (fixP->fx_subsy); @@ -3441,14 +3413,14 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) fixP->fx_addnumber = value; } - if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED) + if (fixP->fx_r_type >= BFD_RELOC_UNUSED) { int opindex; const struct v850_operand *operand; unsigned long insn; const char *errmsg = NULL; - opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED; + opindex = fixP->fx_r_type - BFD_RELOC_UNUSED; operand = &v850_operands[opindex]; /* Fetch the instruction, insert the fully resolved operand @@ -3459,9 +3431,9 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) where = fixP->fx_frag->fr_literal + fixP->fx_where; if (fixP->fx_size > 2) - insn = bfd_getl32 ((unsigned char *) where); + insn = bfd_getl32 (where); else - insn = bfd_getl16 ((unsigned char *) where); + insn = bfd_getl16 (where); /* When inserting loop offsets a backwards displacement is encoded as a positive value. */ @@ -3474,9 +3446,9 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) as_warn_where (fixP->fx_file, fixP->fx_line, "%s", errmsg); if (fixP->fx_size > 2) - bfd_putl32 ((bfd_vma) insn, (unsigned char *) where); + bfd_putl32 (insn, where); else - bfd_putl16 ((bfd_vma) insn, (unsigned char *) where); + bfd_putl16 (insn, where); if (fixP->fx_done) /* Nothing else to do here. */ @@ -3512,7 +3484,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) && ((struct v850_operand *) fixP->tc_fix_data)->insert != NULL) { const char * message = NULL; - struct v850_operand * operand = (struct v850_operand *) fixP->tc_fix_data; + struct v850_operand * operand = fixP->tc_fix_data; unsigned long insn; /* The variable "where" currently points at the exact point inside @@ -3525,14 +3497,14 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) else if (fixP->fx_size == 1) where -= 3; - insn = bfd_getl32 ((unsigned char *) where); + insn = bfd_getl32 (where); /* Use the operand's insertion procedure, if present, in order to make sure that the value is correctly stored in the insn. */ insn = operand->insert (insn, (offsetT) value, & message); /* Ignore message even if it is set. */ - bfd_putl32 ((bfd_vma) insn, (unsigned char *) where); + bfd_putl32 (insn, where); } else { @@ -3540,17 +3512,17 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) { case BFD_RELOC_V850_32_ABS: case BFD_RELOC_V850_32_PCREL: - bfd_putl32 (value & 0xfffffffe, (unsigned char *) where); + bfd_putl32 (value & 0xfffffffe, where); break; case BFD_RELOC_32: - bfd_putl32 (value, (unsigned char *) where); + bfd_putl32 (value, where); break; case BFD_RELOC_V850_23: bfd_putl32 (((value & 0x7f) << 4) | ((value & 0x7fff80) << (16-7)) | (bfd_getl32 (where) & ~((0x7f << 4) | (0xffff << 16))), - (unsigned char *) where); + where); break; case BFD_RELOC_16: @@ -3561,7 +3533,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_V850_SDA_16_16_OFFSET: case BFD_RELOC_V850_TDA_16_16_OFFSET: case BFD_RELOC_V850_CALLT_16_16_OFFSET: - bfd_putl16 (value & 0xffff, (unsigned char *) where); + bfd_putl16 (value & 0xffff, where); break; case BFD_RELOC_8: @@ -3580,7 +3552,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_V850_16_PCREL: bfd_putl16 ((-value & 0xfffe) | (bfd_getl16 (where + 2) & 0x0001), - (unsigned char *) (where + 2)); + where + 2); break; case BFD_RELOC_V850_22_PCREL: @@ -3592,7 +3564,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_V850_LO16_S1: case BFD_RELOC_V850_ZDA_15_16_OFFSET: case BFD_RELOC_V850_SDA_15_16_OFFSET: - bfd_putl16 (value & 0xfffe, (unsigned char *) where); + bfd_putl16 (value & 0xfffe, where); break; case BFD_RELOC_V850_16_SPLIT_OFFSET: @@ -3748,7 +3720,7 @@ v850_md_finish (void) /* Write the note type. */ p = frag_more (4); - md_number_to_chars (p, (valueT) id, 4); + md_number_to_chars (p, id, 4); /* Write the name field. */ p = frag_more (4); |