void cfi_finish (void) { segT cfi_seg; struct fde_entry *fde; int save_flag_traditional_format; if (all_fde_data == 0) return; /* Open .eh_frame section. */ cfi_seg = subseg_new (".eh_frame", 0); bfd_set_section_flags (stdoutput, cfi_seg, SEC_ALLOC | SEC_LOAD | SEC_DATA | DWARF2_EH_FRAME_READ_ONLY); subseg_set (cfi_seg, 0); record_alignment (cfi_seg, EH_FRAME_ALIGNMENT); #ifdef md_fix_up_eh_frame md_fix_up_eh_frame (cfi_seg); #endif /* Make sure check_eh_frame doesn't do anything with our output. */ save_flag_traditional_format = flag_traditional_format; flag_traditional_format = 1; for (fde = all_fde_data; fde ; fde = fde->next) { struct cfi_insn_data *first; struct cie_entry *cie; if (fde->end_address == NULL) { as_bad (_("open CFI at the end of file; missing .cfi_endproc directive")); fde->end_address = fde->start_address; } cie = select_cie_for_fde (fde, &first); output_fde (fde, cie, first, fde->next == NULL ? EH_FRAME_ALIGNMENT : 2); } flag_traditional_format = save_flag_traditional_format; }
static segT get_cfi_seg (segT cseg, const char *base, flagword flags, int align) { if (SUPPORT_FRAME_LINKONCE) { 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; }
void dwarf2_finish (void) { segT line_seg; struct line_seg *s; segT info_seg; int emit_other_sections = 0; int empty_debug_line = 0; info_seg = bfd_get_section_by_name (stdoutput, ".debug_info"); emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg); line_seg = bfd_get_section_by_name (stdoutput, ".debug_line"); empty_debug_line = line_seg == NULL || !seg_not_empty_p (line_seg); /* We can't construct a new debug_line section if we already have one. Give an error. */ if (all_segs && !empty_debug_line) as_fatal ("duplicate .debug_line sections"); if ((!all_segs && emit_other_sections) || (!emit_other_sections && !empty_debug_line)) /* If there is no line information and no non-empty .debug_info section, or if there is both a non-empty .debug_info and a non-empty .debug_line, then we do nothing. */ return; /* Calculate the size of an address for the target machine. */ sizeof_address = DWARF2_ADDR_SIZE (stdoutput); /* Create and switch to the line number section. */ line_seg = subseg_new (".debug_line", 0); bfd_set_section_flags (stdoutput, line_seg, SEC_READONLY | SEC_DEBUGGING); /* For each subsection, chain the debug entries together. */ for (s = all_segs; s; s = s->next) { struct line_subseg *lss = s->head; struct line_entry **ptail = lss->ptail; while ((lss = lss->next) != NULL) { *ptail = lss->head; ptail = lss->ptail; } } out_debug_line (line_seg); /* If this is assembler generated line info, and there is no debug_info already, we need .debug_info and .debug_abbrev sections as well. */ if (emit_other_sections) { segT abbrev_seg; segT aranges_seg; segT ranges_seg; gas_assert (all_segs); info_seg = subseg_new (".debug_info", 0); abbrev_seg = subseg_new (".debug_abbrev", 0); aranges_seg = subseg_new (".debug_aranges", 0); bfd_set_section_flags (stdoutput, info_seg, SEC_READONLY | SEC_DEBUGGING); bfd_set_section_flags (stdoutput, abbrev_seg, SEC_READONLY | SEC_DEBUGGING); bfd_set_section_flags (stdoutput, aranges_seg, SEC_READONLY | SEC_DEBUGGING); record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1); if (all_segs->next == NULL) ranges_seg = NULL; else { ranges_seg = subseg_new (".debug_ranges", 0); bfd_set_section_flags (stdoutput, ranges_seg, SEC_READONLY | SEC_DEBUGGING); record_alignment (ranges_seg, ffs (2 * sizeof_address) - 1); out_debug_ranges (ranges_seg); } out_debug_aranges (aranges_seg, info_seg); out_debug_abbrev (abbrev_seg, info_seg, line_seg); out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg); } }
void dwarf2_finish (void) { segT line_seg; struct line_seg *s; /* We don't need to do anything unless: - Some debug information was recorded via .file/.loc - or, we are generating DWARF2 information ourself (--gdwarf2) - or, there is a user-provided .debug_info section which could reference the file table in the .debug_line section we generate below. */ if (all_segs == NULL && debug_type != DEBUG_DWARF2 && bfd_get_section_by_name (stdoutput, ".debug_info") == NULL) return; /* Calculate the size of an address for the target machine. */ sizeof_address = DWARF2_ADDR_SIZE (stdoutput); /* Create and switch to the line number section. */ line_seg = subseg_new (".debug_line", 0); bfd_set_section_flags (stdoutput, line_seg, SEC_READONLY); /* For each subsection, chain the debug entries together. */ for (s = all_segs; s; s = s->next) { struct line_subseg *ss = s->head; struct line_entry **ptail = ss->ptail; while ((ss = ss->next) != NULL) { *ptail = ss->head; ptail = ss->ptail; } } out_debug_line (line_seg); /* If this is assembler generated line info, we need .debug_info and .debug_abbrev sections as well. */ if (all_segs != NULL && debug_type == DEBUG_DWARF2) { segT abbrev_seg; segT info_seg; segT aranges_seg; info_seg = subseg_new (".debug_info", 0); abbrev_seg = subseg_new (".debug_abbrev", 0); aranges_seg = subseg_new (".debug_aranges", 0); bfd_set_section_flags (stdoutput, info_seg, SEC_READONLY); bfd_set_section_flags (stdoutput, abbrev_seg, SEC_READONLY); bfd_set_section_flags (stdoutput, aranges_seg, SEC_READONLY); record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1); out_debug_aranges (aranges_seg, info_seg); out_debug_abbrev (abbrev_seg); out_debug_info (info_seg, abbrev_seg, line_seg); } }
static void even (int ignore ATTRIBUTE_UNUSED) { frag_align (1, 0, 0); record_alignment (now_seg, 1); }
void dwarf2_finish (void) { segT line_seg; struct line_seg *s; segT info_seg; int emit_other_sections = 0; info_seg = bfd_get_section_by_name (stdoutput, ".debug_info"); emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg); if (!all_segs && emit_other_sections) /* There is no line information and no non-empty .debug_info section. */ return; /* Calculate the size of an address for the target machine. */ sizeof_address = DWARF2_ADDR_SIZE (stdoutput); /* Create and switch to the line number section. */ line_seg = subseg_new (".debug_line", 0); bfd_set_section_flags (stdoutput, line_seg, SEC_READONLY | SEC_DEBUGGING); /* For each subsection, chain the debug entries together. */ for (s = all_segs; s; s = s->next) { struct line_subseg *ss = s->head; struct line_entry **ptail = ss->ptail; while ((ss = ss->next) != NULL) { *ptail = ss->head; ptail = ss->ptail; } } out_debug_line (line_seg); /* If this is assembler generated line info, and there is no debug_info already, we need .debug_info and .debug_abbrev sections as well. */ if (emit_other_sections) { segT abbrev_seg; segT aranges_seg; assert (all_segs); info_seg = subseg_new (".debug_info", 0); abbrev_seg = subseg_new (".debug_abbrev", 0); aranges_seg = subseg_new (".debug_aranges", 0); bfd_set_section_flags (stdoutput, info_seg, SEC_READONLY | SEC_DEBUGGING); bfd_set_section_flags (stdoutput, abbrev_seg, SEC_READONLY | SEC_DEBUGGING); bfd_set_section_flags (stdoutput, aranges_seg, SEC_READONLY | SEC_DEBUGGING); record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1); out_debug_aranges (aranges_seg, info_seg); out_debug_abbrev (abbrev_seg); out_debug_info (info_seg, abbrev_seg, line_seg); } }