yasm_section * yasm_dwarf2__generate_aranges(yasm_object *object, yasm_section *debug_info) { yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; int new; yasm_section *debug_aranges; yasm_bytecode *bc; dwarf2_head *head; dwarf2_aranges_info info; debug_aranges = yasm_object_get_general(object, ".debug_aranges", 2*dbgfmt_dwarf2->sizeof_address, 0, 0, &new, 0); /* header */ head = yasm_dwarf2__add_head(dbgfmt_dwarf2, debug_aranges, debug_info, 1, 1); /* align ranges to 2x address size (range size) */ bc = yasm_bc_create_align( yasm_expr_create_ident(yasm_expr_int( yasm_intnum_create_uint(dbgfmt_dwarf2->sizeof_address*2)), 0), NULL, NULL, NULL, 0); yasm_bc_finalize(bc, yasm_dwarf2__append_bc(debug_aranges, bc)); yasm_bc_calc_len(bc, NULL, NULL); info.debug_aranges = debug_aranges; info.object = object; info.dbgfmt_dwarf2 = dbgfmt_dwarf2; yasm_object_sections_traverse(object, (void *)&info, dwarf2_generate_aranges_section); /* Terminate with empty address range descriptor */ dwarf2_append_arange(debug_aranges, yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0), yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0), dbgfmt_dwarf2->sizeof_address); /* mark end of aranges information */ yasm_dwarf2__set_head_end(head, yasm_section_bcs_last(debug_aranges)); return debug_aranges; }
static void xdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, yasm_errwarns *errwarns) { yasm_objfmt_xdf *objfmt_xdf = (yasm_objfmt_xdf *)object->objfmt; xdf_objfmt_output_info info; unsigned char *localbuf; unsigned long symtab_count = 0; info.object = object; info.objfmt_xdf = objfmt_xdf; info.errwarns = errwarns; info.f = f; info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE); /* Allocate space for headers by seeking forward */ if (fseek(f, (long)(16+40*(objfmt_xdf->parse_scnum)), SEEK_SET) < 0) { yasm__fatal(N_("could not seek on output file")); /*@notreached@*/ return; } /* Get number of symbols */ info.indx = 0; info.all_syms = 1; /* force all syms into symbol table */ yasm_symtab_traverse(object->symtab, &info, xdf_objfmt_count_sym); symtab_count = info.indx; /* Get file offset of start of string table */ info.strtab_offset = 16+40*(objfmt_xdf->parse_scnum)+16*symtab_count; /* Output symbol table */ yasm_symtab_traverse(object->symtab, &info, xdf_objfmt_output_sym); /* Output string table */ yasm_symtab_traverse(object->symtab, &info, xdf_objfmt_output_str); /* Section data/relocs */ if (yasm_object_sections_traverse(object, &info, xdf_objfmt_output_section)) return; /* Write headers */ if (fseek(f, 0, SEEK_SET) < 0) { yasm__fatal(N_("could not seek on output file")); /*@notreached@*/ return; } localbuf = info.buf; YASM_WRITE_32_L(localbuf, XDF_MAGIC); /* magic number */ YASM_WRITE_32_L(localbuf, objfmt_xdf->parse_scnum); /* number of sects */ YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */ /* size of sect headers + symbol table + strings */ YASM_WRITE_32_L(localbuf, info.strtab_offset-16); fwrite(info.buf, 16, 1, f); yasm_object_sections_traverse(object, &info, xdf_objfmt_output_secthead); yasm_xfree(info.buf); }