From ed67db7ab98d6272e1d4590118d5e383b2ff413a Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Wed, 4 Apr 2001 04:23:20 +0000 Subject: [PATCH] * config/tc-cris.c (cris_insn_first_word_frag): New. (md_assemble): Call cris_insn_first_word_frag to get the first frag in an insn, not frag_more. Don't call dwarf2_emit_insn at end. Drop variable insn_size. (gen_bdap): Call cris_insn_first_word_frag, not frag_more. (cris_sym_leading_underscore): Wrap first as_bad parameter in _(). (cris_sym_no_leading_underscore, s_cris_file, s_cris_loc): Ditto. --- gas/ChangeLog | 7 +++++++ gas/config/tc-cris.c | 50 ++++++++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index bb24ea84b3f..fdae672c909 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -5,6 +5,13 @@ 32-bit branch, just set fragP->fr_subtype. Set fragP->fr_var. : Always set fragP->fr_var using md_cris_relax_table. Add cases to cover all relax states. + (cris_insn_first_word_frag): New. + (md_assemble): Call cris_insn_first_word_frag to get the first + frag in an insn, not frag_more. Don't call dwarf2_emit_insn at + end. Drop variable insn_size. + (gen_bdap): Call cris_insn_first_word_frag, not frag_more. + (cris_sym_leading_underscore): Wrap first as_bad parameter in _(). + (cris_sym_no_leading_underscore, s_cris_file, s_cris_loc): Ditto. * write.c (write_object_file): Reset broken word state before calling relax_seg. diff --git a/gas/config/tc-cris.c b/gas/config/tc-cris.c index 0b11f38889d..19ae971190e 100644 --- a/gas/config/tc-cris.c +++ b/gas/config/tc-cris.c @@ -145,6 +145,7 @@ static void cris_force_reg_prefix PARAMS ((void)); static void cris_relax_reg_prefix PARAMS ((void)); static void cris_sym_leading_underscore PARAMS ((void)); static void cris_sym_no_leading_underscore PARAMS ((void)); +static char *cris_insn_first_word_frag PARAMS ((void)); /* Handle to the opcode hash table. */ static struct hash_control *op_hash = NULL; @@ -649,6 +650,26 @@ md_create_long_jump (storep, from_addr, to_addr, fragP, to_symbol) } } +/* Allocate space for the first piece of an insn, and mark it as the + start of the insn for debug-format use. */ + +static char * +cris_insn_first_word_frag () +{ + char *insnp = frag_more (2); + + /* We need to mark the start of the insn by passing dwarf2_emit_insn + the offset from the current fragment position. This must be done + after the first fragment is created but before any other fragments + (fixed or varying) are created. Note that the offset only + corresponds to the "size" of the insn for a fixed-size, + non-expanded insn. */ + if (OUTPUT_FLAVOR == bfd_target_elf_flavour) + dwarf2_emit_insn (2); + + return insnp; +} + /* Port-specific assembler initialization. */ void @@ -693,7 +714,6 @@ md_assemble (str) struct cris_prefix prefix; char *opcodep; char *p; - int insn_size = 0; know (str); @@ -721,8 +741,7 @@ md_assemble (str) case PREFIX_BDAP: case PREFIX_BIAP: case PREFIX_DIP: - insn_size += 2; - opcodep = frag_more (2); + opcodep = cris_insn_first_word_frag (); /* Output the prefix opcode. */ md_number_to_chars (opcodep, (long) prefix.opcode, 2); @@ -736,7 +755,6 @@ md_assemble (str) = (prefix.kind == PREFIX_DIP ? 4 : cris_get_pic_reloc_size (prefix.reloc)); - insn_size += relocsize; p = frag_more (relocsize); fix_new_exp (frag_now, (p - frag_now->fr_literal), relocsize, &prefix.expr, 0, prefix.reloc); @@ -744,8 +762,7 @@ md_assemble (str) break; case PREFIX_PUSH: - insn_size += 2; - opcodep = frag_more (2); + opcodep = cris_insn_first_word_frag (); /* Output the prefix opcode. Being a "push", we add the negative size of the register to "sp". */ @@ -771,8 +788,10 @@ md_assemble (str) return; /* Done with the prefix. Continue with the main instruction. */ - insn_size += 2; - opcodep = frag_more (2); + if (prefix.kind == PREFIX_NONE) + opcodep = cris_insn_first_word_frag (); + else + opcodep = frag_more (2); /* Output the instruction opcode. */ md_number_to_chars (opcodep, (long) (output_instruction.opcode), 2); @@ -820,7 +839,6 @@ md_assemble (str) branch. */ char *cond_jump = frag_more (10); - insn_size += 10; gen_cond_branch_32 (opcodep, cond_jump, frag_now, output_instruction.expr.X_add_symbol, (symbolS *) NULL, @@ -861,7 +879,6 @@ md_assemble (str) BAD_CASE (output_instruction.imm_oprnd_size); } - insn_size += output_instruction.imm_oprnd_size; p = frag_more (output_instruction.imm_oprnd_size); fix_new_exp (frag_now, (p - frag_now->fr_literal), output_instruction.imm_oprnd_size, @@ -881,9 +898,6 @@ md_assemble (str) output_instruction.reloc); } } - - if (OUTPUT_FLAVOR == bfd_target_elf_flavour) - dwarf2_emit_insn (insn_size); } /* Low level text-to-bits assembly. */ @@ -2337,7 +2351,7 @@ gen_bdap (base_regno, exprP) /* Put out the prefix opcode; assume quick immediate mode at first. */ opcode = BDAP_QUICK_OPCODE | (base_regno << 12); - opcodep = frag_more (2); + opcodep = cris_insn_first_word_frag (); md_number_to_chars (opcodep, opcode, 2); if (exprP->X_op == O_constant) @@ -3100,7 +3114,7 @@ static void cris_sym_leading_underscore () the bfd is already created. */ if (symbols_have_leading_underscore == false) - as_bad (".syntax %s requires command-line option `--underscore'", + as_bad (_(".syntax %s requires command-line option `--underscore'"), SYNTAX_USER_SYM_LEADING_UNDERSCORE); } @@ -3109,7 +3123,7 @@ static void cris_sym_leading_underscore () static void cris_sym_no_leading_underscore () { if (symbols_have_leading_underscore == true) - as_bad (".syntax %s requires command-line option `--no-underscore'", + as_bad (_(".syntax %s requires command-line option `--no-underscore'"), SYNTAX_USER_SYM_NO_LEADING_UNDERSCORE); } @@ -3158,7 +3172,7 @@ s_cris_file (dummy) int dummy; { if (OUTPUT_FLAVOR != bfd_target_elf_flavour) - as_bad ("Pseudodirective .file is only valid when generating ELF"); + as_bad (_("Pseudodirective .file is only valid when generating ELF")); else dwarf2_directive_file (dummy); } @@ -3171,7 +3185,7 @@ s_cris_loc (dummy) int dummy; { if (OUTPUT_FLAVOR != bfd_target_elf_flavour) - as_bad ("Pseudodirective .loc is only valid when generating ELF"); + as_bad (_("Pseudodirective .loc is only valid when generating ELF")); else dwarf2_directive_loc (dummy); } -- 2.30.2