+static void
+dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED)
+{
+ struct cfi_insn_data *insn_ptr;
+ offsetT encoding;
+
+ if (frchain_now->frch_cfi_data == NULL)
+ {
+ as_bad (_("CFI instruction used without previous .cfi_startproc"));
+ ignore_rest_of_line ();
+ 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 ());
+
+ insn_ptr = alloc_cfi_insn_data ();
+ insn_ptr->insn = CFI_val_encoded_addr;
+
+ insn_ptr->u.ea.reg = cfi_parse_reg ();
+
+ cfi_parse_separator ();
+ encoding = cfi_parse_const ();
+ if ((encoding & 0xff) != encoding
+ || ((encoding & 0x70) != 0
+#if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
+ && (encoding & 0x70) != DW_EH_PE_pcrel
+#endif
+ )
+ /* leb128 can be handled, but does something actually need it? */
+ || (encoding & 7) == DW_EH_PE_uleb128
+ || (encoding & 7) > DW_EH_PE_udata8)
+ {
+ as_bad (_("invalid or unsupported encoding in .cfi_lsda"));
+ encoding = DW_EH_PE_omit;
+ }
+
+ cfi_parse_separator ();
+ expression_and_evaluate (&insn_ptr->u.ea.exp);
+ switch (insn_ptr->u.ea.exp.X_op)
+ {
+ case O_symbol:
+ break;
+ case O_constant:
+ if ((encoding & 0x70) != DW_EH_PE_pcrel)
+ break;
+ /* Fall through. */
+ default:
+ encoding = DW_EH_PE_omit;
+ break;
+ }
+
+ 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;
+
+ if (frchain_now->frch_cfi_data == NULL)
+ {
+ as_bad (_("CFI instruction used without previous .cfi_startproc"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ 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 (startswith (name, ".eh_frame")
+ && name[9] != '_')
+ sections |= CFI_EMIT_eh_frame;
+ else if (startswith (name, ".debug_frame"))
+ sections |= CFI_EMIT_debug_frame;
+#if SUPPORT_COMPACT_EH
+ else if (startswith (name, ".eh_frame_entry"))
+ {
+ 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
+ && (sections & (CFI_EMIT_eh_frame | CFI_EMIT_eh_frame_compact))
+ && ((cfi_sections & (CFI_EMIT_eh_frame | CFI_EMIT_eh_frame_compact))
+ != (sections & (CFI_EMIT_eh_frame | CFI_EMIT_eh_frame_compact))))
+ 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 (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;
+
+ while (align_padding-- > 0)
+ *(p++) = tc_compact_eh_opcode_pad;
+
+ *(p++) = tc_compact_eh_opcode_stop;
+ fde->eh_header_type = EH_COMPACT_OUTLINE_DONE;
+}
+
+/* Handle the .cfi_inline_lsda directive. */
+static void
+dot_cfi_inline_lsda (int ignored ATTRIBUTE_UNUSED)
+{
+ segT ccseg;
+ int align;
+ long max_alignment = 28;
+
+ if (!last_fde)
+ {
+ as_bad (_("unexpected .cfi_inline_lsda"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ if ((last_fde->sections & CFI_EMIT_eh_frame_compact) == 0)
+ {
+ as_bad (_(".cfi_inline_lsda not valid for this frame"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ if (last_fde->eh_header_type != EH_COMPACT_UNKNOWN
+ && last_fde->eh_header_type != EH_COMPACT_HAS_LSDA)
+ {
+ as_bad (_(".cfi_inline_lsda seen for frame without .cfi_lsda"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+#ifdef md_flush_pending_output
+ md_flush_pending_output ();
+#endif
+
+ align = get_absolute_expression ();
+ if (align > max_alignment)
+ {
+ align = max_alignment;
+ as_bad (_("Alignment too large: %d. assumed."), align);
+ }
+ else if (align < 0)
+ {
+ as_warn (_("Alignment negative: 0 assumed."));
+ align = 0;
+ }
+
+ demand_empty_rest_of_line ();
+ ccseg = CUR_SEG (last_fde);
+
+ /* Open .gnu_extab section. */
+ get_cfi_seg (ccseg, ".gnu_extab",
+ (SEC_ALLOC | SEC_LOAD | SEC_DATA
+ | DWARF2_EH_FRAME_READ_ONLY),
+ 1);