+ }
+
+ insn_ptr->u.ea.encoding = encoding;
+ if (encoding == DW_EH_PE_omit)
+ {
+ as_bad (_("wrong third argument to .cfi_val_encoded_addr"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ demand_empty_rest_of_line ();
+}
+
+static void
+dot_cfi_label (int ignored ATTRIBUTE_UNUSED)
+{
+ char *name = read_symbol_name ();
+
+ if (name == NULL)
+ return;
+
+ /* If the last address was not at the current PC, advance to current. */
+ if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now
+ || S_GET_VALUE (frchain_now->frch_cfi_data->last_address)
+ != frag_now_fix ())
+ cfi_add_advance_loc (symbol_temp_new_now ());
+
+ cfi_add_label (name);
+ free (name);
+
+ demand_empty_rest_of_line ();
+}
+
+static void
+dot_cfi_sections (int ignored ATTRIBUTE_UNUSED)
+{
+ int sections = 0;
+
+ SKIP_WHITESPACE ();
+ if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"')
+ while (1)
+ {
+ char * saved_ilp;
+ char *name, c;
+
+ saved_ilp = input_line_pointer;
+ c = get_symbol_name (& name);
+
+ if (strncmp (name, ".eh_frame", sizeof ".eh_frame") == 0
+ && name[9] != '_')
+ sections |= CFI_EMIT_eh_frame;
+ else if (strncmp (name, ".debug_frame", sizeof ".debug_frame") == 0)
+ sections |= CFI_EMIT_debug_frame;
+#if SUPPORT_COMPACT_EH
+ else if (strncmp (name, ".eh_frame_entry", sizeof ".eh_frame_entry") == 0)
+ {
+ compact_eh = TRUE;
+ sections |= CFI_EMIT_eh_frame_compact;
+ }
+#endif
+#ifdef tc_cfi_section_name
+ else if (strcmp (name, tc_cfi_section_name) == 0)
+ sections |= CFI_EMIT_target;
+#endif
+ else
+ {
+ *input_line_pointer = c;
+ input_line_pointer = saved_ilp;
+ break;
+ }
+
+ *input_line_pointer = c;
+ SKIP_WHITESPACE_AFTER_NAME ();
+ if (*input_line_pointer == ',')
+ {
+ name = input_line_pointer++;
+ SKIP_WHITESPACE ();
+ if (!is_name_beginner (*input_line_pointer) && *input_line_pointer != '"')
+ {
+ input_line_pointer = name;
+ break;
+ }
+ }
+ else if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"')
+ break;
+ }
+
+ demand_empty_rest_of_line ();
+ if (cfi_sections_set && cfi_sections != sections)
+ as_bad (_("inconsistent uses of .cfi_sections"));
+ cfi_sections = sections;
+}
+
+static void
+dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
+{
+ int simple = 0;
+
+ if (frchain_now->frch_cfi_data != NULL)
+ {
+ as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ cfi_new_fde (symbol_temp_new_now ());
+
+ SKIP_WHITESPACE ();
+ if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"')
+ {
+ char * saved_ilp = input_line_pointer;
+ char *name, c;
+
+ c = get_symbol_name (& name);
+
+ if (strcmp (name, "simple") == 0)
+ {
+ simple = 1;
+ restore_line_pointer (c);
+ }
+ else
+ input_line_pointer = saved_ilp;
+ }
+ demand_empty_rest_of_line ();
+
+ cfi_sections_set = TRUE;
+ all_cfi_sections |= cfi_sections;
+ cfi_set_sections ();
+ frchain_now->frch_cfi_data->cur_cfa_offset = 0;
+ if (!simple)
+ tc_cfi_frame_initial_instructions ();
+
+ if ((cfi_sections & CFI_EMIT_target) != 0)
+ tc_cfi_startproc ();
+}
+
+static void
+dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED)
+{
+ if (frchain_now->frch_cfi_data == NULL)
+ {
+ as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ last_fde = frchain_now->frch_cfi_data->cur_fde_data;
+
+ cfi_end_fde (symbol_temp_new_now ());
+
+ demand_empty_rest_of_line ();
+
+ cfi_sections_set = TRUE;
+ if ((cfi_sections & CFI_EMIT_target) != 0)
+ tc_cfi_endproc (last_fde);
+}
+
+static segT
+get_cfi_seg (segT cseg, const char *base, flagword flags, int align)
+{
+ /* Exclude .debug_frame sections for Compact EH. */
+ if (SUPPORT_FRAME_LINKONCE || ((flags & SEC_DEBUGGING) == 0 && compact_eh))
+ {
+ struct dwcfi_seg_list *l;
+
+ l = dwcfi_hash_find_or_make (cseg, base, flags);
+
+ cseg = l->seg;
+ subseg_set (cseg, l->subseg);
+ }
+ else
+ {
+ cseg = subseg_new (base, 0);
+ bfd_set_section_flags (stdoutput, cseg, flags);
+ }
+ record_alignment (cseg, align);
+ return cseg;
+}
+
+#if SUPPORT_COMPACT_EH
+static void
+dot_cfi_personality_id (int ignored ATTRIBUTE_UNUSED)
+{
+ struct fde_entry *fde;
+
+ if (frchain_now->frch_cfi_data == NULL)
+ {
+ as_bad (_("CFI instruction used without previous .cfi_startproc"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ fde = frchain_now->frch_cfi_data->cur_fde_data;
+ fde->personality_id = cfi_parse_const ();
+ demand_empty_rest_of_line ();
+
+ if (fde->personality_id == 0 || fde->personality_id > 3)
+ {
+ as_bad (_("wrong argument to .cfi_personality_id"));
+ return;
+ }
+}
+
+static void
+dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED)
+{
+ if (frchain_now->frch_cfi_data == NULL)
+ {
+ as_bad (_(".cfi_fde_data without corresponding .cfi_startproc"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ last_fde = frchain_now->frch_cfi_data->cur_fde_data;
+
+ cfi_sections_set = TRUE;
+ if ((cfi_sections & CFI_EMIT_target) != 0
+ || (cfi_sections & CFI_EMIT_eh_frame_compact) != 0)
+ {
+ struct cfi_escape_data *head, **tail, *e;
+ int num_ops = 0;
+
+ tail = &head;
+ if (!is_it_end_of_statement ())
+ {
+ num_ops = 0;
+ do
+ {
+ e = XNEW (struct cfi_escape_data);
+ do_parse_cons_expression (&e->exp, 1);
+ *tail = e;
+ tail = &e->next;
+ num_ops++;
+ }
+ while (*input_line_pointer++ == ',');
+ --input_line_pointer;
+ }
+ *tail = NULL;
+
+ if (last_fde->lsda_encoding != DW_EH_PE_omit)
+ last_fde->eh_header_type = EH_COMPACT_HAS_LSDA;
+ else if (num_ops <= 3 && last_fde->per_encoding == DW_EH_PE_omit)
+ last_fde->eh_header_type = EH_COMPACT_INLINE;
+ else
+ last_fde->eh_header_type = EH_COMPACT_OUTLINE;
+
+ if (last_fde->eh_header_type == EH_COMPACT_INLINE)
+ num_ops = 3;
+
+ last_fde->eh_data_size = num_ops;
+ last_fde->eh_data = XNEWVEC (bfd_byte, num_ops);
+ num_ops = 0;
+ while (head)
+ {
+ e = head;
+ head = e->next;
+ last_fde->eh_data[num_ops++] = e->exp.X_add_number;
+ free (e);
+ }
+ if (last_fde->eh_header_type == EH_COMPACT_INLINE)
+ while (num_ops < 3)
+ last_fde->eh_data[num_ops++] = tc_compact_eh_opcode_stop;
+ }
+
+ demand_empty_rest_of_line ();
+}
+
+/* Function to emit the compact unwinding opcodes stored in the
+ fde's eh_data field. The end of the opcode data will be
+ padded to the value in align. */
+
+static void
+output_compact_unwind_data (struct fde_entry *fde, int align)
+{
+ int data_size = fde->eh_data_size + 2;
+ int align_padding;
+ int amask;
+ char *p;
+
+ fde->eh_loc = symbol_temp_new_now ();
+
+ p = frag_more (1);
+ if (fde->personality_id != 0)
+ *p = fde->personality_id;
+ else if (fde->per_encoding != DW_EH_PE_omit)
+ {
+ *p = 0;
+ emit_expr_encoded (&fde->personality, fde->per_encoding, FALSE);
+ data_size += encoding_size (fde->per_encoding);
+ }
+ else
+ *p = 1;
+
+ amask = (1 << align) - 1;
+ align_padding = ((data_size + amask) & ~amask) - data_size;
+
+ p = frag_more (fde->eh_data_size + 1 + align_padding);
+ memcpy (p, fde->eh_data, fde->eh_data_size);
+ p += fde->eh_data_size;