void DwarfGenModule( void ) /********************************/ // write out the addr info, and write out the null die at the end of .debug_info { unsigned size; if( CurrMod->modinfo & MOD_DBI_SEEN ) return; if( CurrMod->d.d->arange.size > 0 ) { // write out terminator arange if( FmtData.type & MK_SEGMENTED ) { size = sizeof( segmented_arange_tuple ); } else { size = sizeof( flat_arange_tuple ); } PutInfoNulls( CurrMod->d.d->arange.u.vm_ptr, size ); } // write out terminator pubsym PutInfoNulls( CurrMod->d.d->pubsym.u.vm_ptr, 1 ); }
static void GenSrcModHeader( void ) /*********************************/ // emit header for line number information now that we know where everything // is. { cheesy_module_header mod_hdr; cheesy_file_table file_tbl; cheesy_mapping_table map_tbl; unsigned adjust; if( LineInfo.linestart == 0 ) return; memset( &mod_hdr, 0, sizeof( mod_hdr ) ); mod_hdr.cFile = 1; mod_hdr.cSeg = 1; mod_hdr.range[0] = LineInfo.range; mod_hdr.baseSrcFile[0] = sizeof( mod_hdr ); mod_hdr.seg[0] = LineInfo.seg; mod_hdr.pad = 0; PutInfo( LineInfo.linestart, &mod_hdr, sizeof( mod_hdr ) ); LineInfo.linestart += sizeof( mod_hdr ); file_tbl.cSeg = 1; file_tbl.pad = 0; file_tbl.range[0] = LineInfo.range; file_tbl.name[0] = strlen( CurrMod->name ); file_tbl.baseSrcLn[0] = sizeof( mod_hdr ) + ROUND_UP( sizeof( file_tbl ) + file_tbl.name[0], 4 ); PutInfo( LineInfo.linestart, &file_tbl, sizeof( file_tbl ) ); LineInfo.linestart += sizeof( file_tbl ); PutInfo( LineInfo.linestart, CurrMod->name, file_tbl.name[0] ); LineInfo.linestart += file_tbl.name[0]; adjust = file_tbl.baseSrcLn[0] - sizeof( mod_hdr ) - sizeof( file_tbl ) - file_tbl.name[0]; if( adjust != 0 ) { PutInfoNulls( LineInfo.linestart, adjust ); LineInfo.linestart += adjust; } map_tbl.Seg = mod_hdr.seg[0]; map_tbl.cPair = CurrMod->d.cv->numlines; PutInfo( LineInfo.linestart, &map_tbl, sizeof( map_tbl ) ); memset( &LineInfo, 0, sizeof( LineInfo ) ); }
void DwarfAddModule( mod_entry *mod, section *sect ) /**************************************************/ // this generates the headers needed in the individual sections { arange_prologue arange_hdr; stmt_prologue stmt_hdr; compuhdr_prologue compuhdr; unsigned_8 abbrev_code; size_t namelen; char * buff; unsigned_32 stmt_list; sect = sect; if( (mod->modinfo & MOD_DBI_SEEN) == 0 ) { if( mod->d.d->arange.size > 0 ) { mod->d.d->arange.u.vm_ptr = SectionTable[SECT_DEBUG_ARANGE].vm_ptr + mod->d.d->arange.u.vm_offs; arange_hdr.length = mod->d.d->arange.size - sizeof( unsigned_32 ); arange_hdr.version = 2; arange_hdr.debug_offset = mod->d.d->pubsym.u.vm_offs + SectionTable[SECT_DEBUG_INFO].start; arange_hdr.offset_size = sizeof( offset ); if( FmtData.type & MK_SEGMENTED ) { arange_hdr.segment_size = sizeof( segment ); } else { arange_hdr.segment_size = 0; } // memset( arange_hdr.padding, 0, sizeof( arange_hdr.padding ) ); PutInfo( mod->d.d->arange.u.vm_ptr, (void *)&arange_hdr, sizeof( arange_prologue ) ); mod->d.d->arange.u.vm_ptr += sizeof( arange_prologue ); } mod->d.d->pubsym.u.vm_ptr = SectionTable[SECT_DEBUG_INFO].vm_ptr + mod->d.d->pubsym.u.vm_offs; compuhdr.length = mod->d.d->pubsym.size - sizeof( unsigned_32 ); compuhdr.version = 2; compuhdr.abbrev_offset = SectionTable[SECT_DEBUG_ABBREV].start; compuhdr.addr_size = sizeof( offset ); PutInfo( mod->d.d->pubsym.u.vm_ptr, (void *)&compuhdr, sizeof( compuhdr ) ); mod->d.d->pubsym.u.vm_ptr += sizeof( compuhdr ); /* output abbrev code */ if( mod->d.d->dasi.size > 0 ) { abbrev_code = COMPUNIT_ABBREV_CODE; } else { abbrev_code = CU_NOLINE_ABBREV_CODE; } PutInfo( mod->d.d->pubsym.u.vm_ptr, &abbrev_code, sizeof( abbrev_code ) ); mod->d.d->pubsym.u.vm_ptr += sizeof( abbrev_code ); /* output module name */ namelen = strlen( mod->name ) + 1; PutInfo( mod->d.d->pubsym.u.vm_ptr, mod->name, namelen ); mod->d.d->pubsym.u.vm_ptr += namelen; /* output producer */ PutInfo( mod->d.d->pubsym.u.vm_ptr, WLINK_PRODUCER, sizeof( WLINK_PRODUCER ) ); mod->d.d->pubsym.u.vm_ptr += sizeof( WLINK_PRODUCER ); if( mod->d.d->dasi.size > 0 ) { /* output stmts offset */ stmt_list = mod->d.d->dasi.u.vm_offs + SectionTable[SECT_DEBUG_LINE].start; PutInfo( mod->d.d->pubsym.u.vm_ptr, &stmt_list, sizeof( unsigned_32 ) ); mod->d.d->pubsym.u.vm_ptr += sizeof( unsigned_32 ); /* output stmts header */ mod->d.d->dasi.u.vm_ptr = SectionTable[SECT_DEBUG_LINE].vm_ptr + mod->d.d->dasi.u.vm_offs; stmt_hdr.total_length = mod->d.d->dasi.size - sizeof( unsigned_32 ); stmt_hdr.version = 2; stmt_hdr.prologue_length = GetStmtHeaderSize( mod ) - offsetof( stmt_prologue, minimum_instruction_length ); stmt_hdr.minimum_instruction_length = DW_MIN_INSTR_LENGTH; stmt_hdr.default_is_stmt = 1; stmt_hdr.line_base = DWLINE_BASE; stmt_hdr.line_range = DWLINE_RANGE; stmt_hdr.opcode_base = DWLINE_OPCODE_BASE; stmt_hdr.standard_opcode_lengths[0] = 0; stmt_hdr.standard_opcode_lengths[1] = 1; stmt_hdr.standard_opcode_lengths[2] = 1; stmt_hdr.standard_opcode_lengths[3] = 1; stmt_hdr.standard_opcode_lengths[4] = 1; stmt_hdr.standard_opcode_lengths[5] = 0; stmt_hdr.standard_opcode_lengths[6] = 0; stmt_hdr.standard_opcode_lengths[7] = 0; stmt_hdr.standard_opcode_lengths[8] = 0; PutInfo( mod->d.d->dasi.u.vm_ptr, (void *)&stmt_hdr, sizeof( stmt_prologue ) ); mod->d.d->dasi.u.vm_ptr += sizeof( stmt_prologue ); PutInfoNulls( mod->d.d->dasi.u.vm_ptr, 1 ); // no include directories; mod->d.d->dasi.u.vm_ptr += 1; buff = alloca( namelen + 3 ); memcpy( &buff[0], mod->name, namelen ); buff[namelen + 0] = 0; // no directory index buff[namelen + 1] = 0; // no time buff[namelen + 2] = 0; // no length PutInfo( mod->d.d->dasi.u.vm_ptr, buff, namelen + 3 ); mod->d.d->dasi.u.vm_ptr += namelen + 3; PutInfoNulls( mod->d.d->dasi.u.vm_ptr, 1 ); // no more file names mod->d.d->dasi.u.vm_ptr += 1; } } }