コード例 #1
0
ファイル: loadphar.c プロジェクト: Azarien/open-watcom-v2
static void WritePharSimple( unsigned_32 start )
/**********************************************/
{
    simple_header   header;
    unsigned_32     file_size;
    unsigned_32     header_size;
    unsigned_32     extra;
    unsigned_32     temp;

    if( FmtData.type & MK_PHAR_REX ) {
        SeekLoad( start + sizeof(simple_header) );
        extra = start + sizeof( simple_header ) + WritePharRelocs();
        header_size = MAKE_PARA( extra );
        PadLoad( header_size - extra );
    } else {
        SeekLoad( start + MAKE_PARA( sizeof(simple_header) ) );
        header_size = MAKE_PARA( sizeof(simple_header) );    // para align.
    }
    file_size = header_size + WritePharData( start + header_size );
    DBIWrite();
    if( FmtData.type & MK_PHAR_SIMPLE ) {
        _HostU16toTarg( SIMPLE_SIGNATURE, header.signature );
    } else {
        _HostU16toTarg( REX_SIGNATURE, header.signature );
    }
    _HostU16toTarg( file_size % 512U, header.mod_size );
    _HostU16toTarg( (file_size + 511U) / 512U, header.file_size );
    _HostU16toTarg( Root->relocs, header.num_relocs );
    _HostU16toTarg( header_size / 16, header.hdr_size );
    extra = MemorySize() - file_size + header_size + 0xfff;
    temp = FmtData.u.phar.mindata + extra;
    if( temp < FmtData.u.phar.mindata ) temp = 0xffffffff;
    _HostU16toTarg( temp >> 12, header.min_data );
    temp = FmtData.u.phar.maxdata + extra;
    if( temp < FmtData.u.phar.maxdata ) temp = 0xffffffff;
    _HostU16toTarg( temp >> 12, header.max_data );
    _HostU32toTarg( StackAddr.off, header.ESP );
    _HostU16toTarg( 0, header.checksum );
    _HostU32toTarg( StartInfo.addr.off, header.EIP );
    _HostU16toTarg( 0x1E, header.reloc_offset );
    _HostU16toTarg( 0, header.overlay_num );
    /* allow header size to exceed 1M */
    _HostU16toTarg( (header_size / (16*0x10000ul)) + 1, header.always_one );
    SeekLoad( start );
    WriteLoad( &header, sizeof( simple_header ) );
    if( FmtData.type & MK_PHAR_SIMPLE ) {
        PadLoad( 2 );                   // header occupies a full paragraph.
    }
}
コード例 #2
0
static void WriteHeader32( void )
/* write 32-bit device header */
{
    rdos_dev32_header   exe_head;
    unsigned_16         temp16;
    unsigned_32         temp32;

    SeekLoad( 0 );
    _HostU16toTarg( RDOS_SIGNATURE_32, exe_head.signature );
    _HostU32toTarg( StartInfo.addr.off, exe_head.EIP );
    temp32 = (unsigned_32)CodeSize;
    _HostU32toTarg( temp32, exe_head.code_size );
    temp16 = (unsigned_16)FmtData.u.rdos.code_sel;
    _HostU16toTarg( temp16, exe_head.code_sel );
    temp32 = (unsigned_32)DataSize;
    _HostU32toTarg( temp32, exe_head.data_size );
    temp16 = (unsigned_16)FmtData.u.rdos.data_sel;
    _HostU16toTarg( temp16, exe_head.data_sel );
    WriteLoad( &exe_head, sizeof( rdos_dev32_header ) );
}
コード例 #3
0
static void WriteMbootHeader( void )
/* write multiboot header */
{
    struct mb_header   mb_head;
    unsigned_32        temp32;
    unsigned_32        linear = MB_BASE;

    SeekLoad( 0 );
    _HostU32toTarg(0x1BADB002, mb_head.mb_magic );
    _HostU32toTarg(0x00010001, mb_head.mb_flags );
    _HostU32toTarg(0xE4514FFD, mb_head.mb_checksum );
    _HostU32toTarg(linear, mb_head.mb_header_addr );
    _HostU32toTarg(linear, mb_head.mb_load_addr );
    linear += CodeSize + sizeof( struct mb_header );
    _HostU32toTarg(linear, mb_head.mb_load_end_addr );
    _HostU32toTarg(linear, mb_head.mb_bss_end_addr );
    temp32 = MB_BASE + StartInfo.addr.off + sizeof( struct mb_header );
    _HostU32toTarg(temp32, mb_head.mb_entry_addr );
    WriteLoad( &mb_head, sizeof( struct mb_header ) );
}
コード例 #4
0
ファイル: dbgcv.c プロジェクト: JWasm/JWlink
void CVGenLines( lineinfo *info )
/*******************************/
// called during pass 2 linnum processing
{
    ln_off_pair UNALIGN *pair;
    unsigned_32         temp_off;
    unsigned_16         temp_num;
    offset              adjust;
    unsigned long       cvsize;
    unsigned            size;
    segdata             *seg;

    seg = info->seg;
    size = info->size & ~LINE_IS_32BIT;

    if( !( CurrMod->modinfo & DBI_LINE ) )
        return;
    adjust = seg->a.delta + seg->u.leader->seg_addr.off;
    if( LineInfo.offbase == 0 ) { // this is our first time through.
        LineInfo.seg = GetCVSegment( seg->u.leader );
        LineInfo.linestart = SectAddrs[CVSECT_MISC];
        cvsize = sizeof( cheesy_module_header ) + sizeof( cheesy_mapping_table )
            + ROUND_UP( sizeof( cheesy_file_table ) + strlen( CurrMod->name ), 4 );
        LineInfo.offbase = SectAddrs[CVSECT_MISC] + cvsize;
        LineInfo.numbase = LineInfo.offbase
                                + CurrMod->d.cv->numlines * sizeof( unsigned_32 );
        cvsize += CurrMod->d.cv->numlines * sizeof( unsigned_32 );
        cvsize += ROUND_UP( CurrMod->d.cv->numlines * sizeof( unsigned_16 ), 4 );
        GenSubSection( sstSrcModule, cvsize );
        SectAddrs[CVSECT_MISC] += cvsize;
        LineInfo.range.start = adjust;
        LineInfo.range.end = adjust + seg->length;
    } else {
        if( adjust < LineInfo.range.start ) {
            LineInfo.range.start = adjust;
        }
        if( adjust + seg->length > LineInfo.range.end ) {
            LineInfo.range.end = adjust + seg->length;
        }
    }
    pair = (ln_off_pair *)info->data;
    if( info->size & LINE_IS_32BIT ) {
        while( size > 0 ) {
            pair->_386.off += adjust;
            if( pair->_386.off < LineInfo.prevaddr ) {
                LineInfo.needsort = TRUE;
            }
            LineInfo.prevaddr = pair->_386.off;
            _HostU32toTarg( pair->_386.off, temp_off );
            _HostU16toTarg( pair->_386.linnum, temp_num );
            PutInfo( LineInfo.offbase, &temp_off, sizeof( unsigned_32 ) );
            PutInfo( LineInfo.numbase, &temp_num, sizeof( unsigned_16 ) );
            LineInfo.offbase += sizeof( unsigned_32 );
            LineInfo.numbase += sizeof( unsigned_16 );
            pair = (void *)( (char *)pair + sizeof( ln_off_386 ) );
            size -= sizeof( ln_off_386 );
        }
    } else {
        while( size > 0 ) {
            pair->_286.off += adjust;
            if( pair->_286.off < LineInfo.prevaddr ) {
                LineInfo.needsort = TRUE;
            }
            LineInfo.prevaddr = pair->_286.off;
            _HostU16toTarg( pair->_286.off, temp_off );
            _HostU16toTarg( pair->_286.linnum, temp_num );
            PutInfo( LineInfo.offbase, &temp_off, sizeof( unsigned_32 ) );
            PutInfo( LineInfo.numbase, &temp_num, sizeof( unsigned_16 ) );
            LineInfo.offbase += sizeof( unsigned_32 );
            LineInfo.numbase += sizeof( unsigned_16 );
            pair = (void *)( (char *)pair + sizeof( ln_off_286 ) );
            size -= sizeof( ln_off_286 );
        }
    }
}
コード例 #5
0
ファイル: loadzdos.c プロジェクト: Azarien/open-watcom-v2
extern void FiniZdosLoadFile( void )
/*************************************/
{
    zdos_exe_header header;
    unsigned_32     position;
    unsigned_32     size;
    unsigned_32     checksum;

    for( position = 0; position < 4; position ++ )
        header.reserved[position] = 0;
    checksum = ZDOS_SIGNATURE;
    _HostU32toTarg( ZDOS_SIGNATURE, header.signature );
    _HostU32toTarg( StartInfo.addr.off, header.EIP );
    checksum += StackAddr.off;
    _HostU32toTarg( StackAddr.off, header.ESP );
    checksum += StackAddr.off;
    _HostU32toTarg( sizeof( zdos_exe_header ), header.hdr_size );
    checksum += sizeof( zdos_exe_header );
    _HostU32toTarg( Root->relocs, header.num_relocs );
    checksum += Root->relocs;
    _HostU32toTarg( sizeof( zdos_exe_header ), header.reloc_offset );
    checksum += sizeof( zdos_exe_header );
    _HostU32toTarg( FmtData.base, header.reloc_base );
    checksum += FmtData.base;
    SeekLoad( sizeof(zdos_exe_header) );
    position = sizeof( zdos_exe_header ) + WriteZdosRelocs();
    _HostU32toTarg( position, header.image_offset );
    checksum += position;
    size = WriteZdosData( position );
    _HostU32toTarg( size, header.image_size );
    checksum += size;
    position += size;
    _HostU32toTarg( position, header.debug_offset );
    checksum += position;
    size = ( StackAddr.off - FmtData.base ) - size;
    _HostU32toTarg( size, header.extra_size );
    checksum += size;
    _HostU32toTarg( size, header.chk_sum );
    DBIWrite();
    SeekLoad( 0 );
    WriteLoad( &header, sizeof( zdos_exe_header ) );
}