Beispiel #1
0
static void WriteBinData( void )
/**********************************************************/
/* copy code from extra memory to loadfile */
{
    group_entry         *group;
    SECTION             *sect;

    DEBUG(( DBG_BASE, "Writing data" ));
    OrderGroups( CompareDosSegments );
    CurrSect = Root;        // needed for WriteInfo.

    Root->outfile->file_loc = Root->u.file_loc;
    Root->sect_addr = Groups->grp_addr;

/* write groups and relocations */
    for( group = Groups; group != NULL; ) {
        sect = group->section;
        CurrSect = sect;

        if( group->totalsize ) {
            WriteDOSGroup( group );
            CodeSize += group->totalsize;
        }
        group = group->next_group;
    }
}
Beispiel #2
0
static unsigned long WriteDOSData( unsigned_32 mz_hdr_size )
/**********************************************************/
/* copy code from extra memory to loadfile */
{
    group_entry         *group;
    SECTION             *sect;
    unsigned long       header_size;
    outfilelist         *fnode;
    bool                repos;
    unsigned long       root_size;

    DEBUG(( DBG_BASE, "Writing data" ));
    OrderGroups( CompareDosSegments );
    CurrSect = Root;        // needed for WriteInfo.
    header_size = WriteDOSRootRelocs( mz_hdr_size );

    Root->u.file_loc = header_size;
    if( Root->areas != NULL ) {
        Root->outfile->file_loc = header_size + Root->size;
        WalkAllOvl( &AssignFileLocs );
        EmitOvlTable();
    }

// keep track of positions within the file.
    for( fnode = OutFiles; fnode != NULL; fnode = fnode->next ) {
        fnode->file_loc = 0;
    }
    Root->outfile->file_loc = Root->u.file_loc;
    Root->sect_addr = Groups->grp_addr;

/* write groups and relocations */
    root_size = 0;
    for( group = Groups; group != NULL; ) {
        sect = group->section;
        CurrSect = sect;
        fnode = sect->outfile;
        repos = WriteDOSGroup( group );
        group = group->next_group;
        if( ( group == NULL ) || ( sect != group->section ) ) {
            if( sect == Root ) {
                root_size = fnode->file_loc;
            } else {
                WriteDOSSectRelocs( sect, repos );
            }
        }
        if( repos ) {
            SeekLoad( fnode->file_loc );
        }
    }
    return( root_size );
}
Beispiel #3
0
static void WriteRDOSCode( void )
/**********************************************************/
{
    group_entry         *group;
    SECTION             *sect;
    struct seg_leader   *leader;
    SEGDATA             *piece;
    int                 iscode;
    int                 isdata;

    DEBUG(( DBG_BASE, "Writing code" ));
    OrderGroups( CompareDosSegments );
    CurrSect = Root;        // needed for WriteInfo.

    Root->outfile->file_loc = Root->u.file_loc;
    Root->sect_addr = Groups->grp_addr;
    leader = 0;

/* write groups and relocations */
    for( group = Groups; group != NULL; ) {
        if( leader != group->leaders ) {
            iscode = 0;
            isdata = 0;
            leader = group->leaders;
            if( leader && leader->size && Extension == E_RDV ) {
                piece = leader->pieces; 
                if( piece ) {
                    if( piece->iscode && ( leader->seg_addr.seg == FmtData.u.rdos.code_seg ) ) {
                        iscode = 1;
                    }
                    if( ( piece->isidata || piece->isuninit ) && ( leader->seg_addr.seg == FmtData.u.rdos.data_seg ) ) {
                        isdata = 1;
                    }
                }
            }
        }
        sect = group->section;
        CurrSect = sect;

        if( iscode ) {
            sect->u.file_loc = HeaderSize + CodeSize;
            WriteDOSGroup( group );
            if( group->totalsize > group->size )
                PadLoad( group->totalsize - group->size );

            CodeSize += group->totalsize;
        }                
        group = group->next_group;
    }
}
Beispiel #4
0
static void WriteCOMFile( void )
/******************************/
// generate a DOS .COM file.
{
    outfilelist         *fnode;
    group_entry         *group;
    bool                repos;
    unsigned long       root_size;
    signed long         chop;

    if( StartInfo.addr.seg != 0 ) {
        LnkMsg( ERR+MSG_INV_COM_START_ADDR, NULL );
        return;
    }
    if( ( StackAddr.seg != 0 ) || ( StackAddr.off != 0 ) ) {
        LnkMsg( WRN+MSG_STACK_SEG_IGNORED, NULL );
    }
    OrderGroups( CompareDosSegments );
    CurrSect = Root;        // needed for WriteInfo.
    fnode = Root->outfile;
    fnode->file_loc = Root->u.file_loc = 0;
    Root->sect_addr = Groups->grp_addr;

    /* write groups */
    for( group = Groups; group != NULL; group = group->next_group ) {
        chop = SUB_ADDR( group->grp_addr, StartInfo.addr );
        if( chop > 0 ) {
            chop = 0;
        }
        if( (signed long)group->size + chop > 0 ) {
            repos = WriteCOMGroup( group, chop );
            if( repos ) {
                SeekLoad( fnode->file_loc );
            }
        }
#if 0
        if( loc < 0 ) {
            Root->u.file_loc += (unsigned long)loc;  // adjust for missing code
        }
#endif
    }
    root_size = fnode->file_loc;
    if( root_size > (64 * 1024L - 0x200) ) {
        LnkMsg( ERR+MSG_COM_TOO_LARGE, NULL );
    }
    DBIWrite();
}
Beispiel #5
0
static unsigned_32 WritePharData( unsigned file_pos )
/***************************************************/
{
    group_entry         *group;
    outfilelist *       fnode;
    bool                repos;

    DEBUG(( DBG_BASE, "Writing data" ));
    OrderGroups( CompareOffsets );
    CurrSect = Root;        // needed for WriteInfo.
    fnode = Root->outfile;
    fnode->file_loc = file_pos;
    Root->u.file_loc = file_pos;
    Root->sect_addr = Groups->grp_addr;
    for( group = Groups; group != NULL; group = group->next_group ) {
        repos = WriteDOSGroup( group );
        if( repos ) {
            SeekLoad( fnode->file_loc );
        }
    }
    return( fnode->file_loc - file_pos );
}