Пример #1
0
static void writeAuxInfo( AUX_INFO *info, unsigned index )
{
    hw_reg_set  *regs;
    hw_reg_set  *save_parms;
    char        *save_objname;
    unsigned    len;

    info->index = index;
    save_parms = info->parms;
    save_objname = info->objname;
    if( save_parms != NULL ) {
        len = 0;
        regs = save_parms;
        for(;;) {
            len += sizeof( hw_reg_set );
            if( HW_CEqual( *regs, HW_EMPTY ) ) break;
            ++regs;
        }
        info->parms = PCHSetUInt( len );
    }
    if( save_objname != NULL ) {
        info->objname = PCHSetUInt( strlen( save_objname ) + 1 );
    }
    PCHWriteVar( *info );
    AsmSysPCHWriteCode( info );
    if( save_parms != NULL ) {
        PCHWrite( save_parms, PCHGetUInt( info->parms ) );
    }
    if( save_objname != NULL ) {
        PCHWrite( save_objname, PCHGetUInt( info->objname ) );
    }
    info->parms = save_parms;
    info->objname = save_objname;
}
Пример #2
0
pch_status PCHWriteFrontData( void )
{
    CGFILE *tmp_cgfile;

    tmp_cgfile = CGFileGetIndex( dataCGFILE );
    PCHWrite( &tmp_cgfile, sizeof( tmp_cgfile ) );
    tmp_cgfile = CGFileGetIndex( codeCGFILE );
    PCHWrite( &tmp_cgfile, sizeof( tmp_cgfile ) );
    return( PCHCB_OK );
}
Пример #3
0
pch_status PCHWriteVerify( void )
/*******************************/
{
    NamePCHWrite( pchDebugInfoName );
    PCHWrite( "WATCOM-PCH", 10 );
    return( PCHCB_OK );
}
Пример #4
0
static void alignPCH( unsigned i, bool writing )
{
    unsigned skip;
    char dummy[PCH_ALIGN] = {0};

    if( writing ) {
        skip = - cursorWriteFilePosition();
        skip &= PCH_ALIGN - 1;
        PCHWriteUInt( skip );
        DbgAssert( skip == 0 );
        if( skip != 0 ) {
            PCHWrite( dummy, skip );
        }
    } else {
        skip = PCHReadUInt();
        if( skip != 0 ) {
            PCHRead( dummy, skip );
        }
    }
#ifndef NDEBUG
    if( writing ) {
        unsigned w = -i;
        PCHWriteUInt( w );
    } else {
        unsigned r;
        r = PCHReadUInt();
        if( r != -i ) {
            printf( "index = %u\n", i );
            CFatal( "pre-compiled header read/write out of synch" );
        }
    }
#else
    i = i;
#endif
}
Пример #5
0
static void dumpFileString( char *str )
{
    unsigned len;

    len = strlen( str ) + 1;
    PCHWriteUInt( len );
    PCHWrite( str, len );
}
Пример #6
0
void CgInfoLibPCHWrite( void )
/****************************/
{
    size_t len;
    LIB_LIST *lib;

    RingIterBeg( libRing, lib ) {
        len = sizeof( *lib ) + strlen( lib->name );
        PCHWriteUInt( len );
        PCHWrite( lib, len );
    } RingIterEnd( lib )
Пример #7
0
static void saveConstant( void *e, carve_walk_base *d )
{
    POOL_CON *fcon = e;
    POOL_CON *save_next;

    if( fcon->free ) {
        return;
    }
    save_next = fcon->next;
    fcon->next = ConstantPoolGetIndex( save_next );
    PCHWriteCVIndex( d->index );
    PCHWriteVar( *fcon );
    if( fcon->flt ) {
        PCHWrite( fcon->u.s.fp_constant, fcon->u.s.len );
    }
    fcon->next = save_next;
}
Пример #8
0
pch_status PCHWritePragmas( void )
{
    unsigned    index;
    unsigned    len;
    AUX_INFO    *info;
    AUX_ENTRY   *e;

    // get aux_info count
    for( e = AuxList; e != NULL; e = e->next ) {
        e->info->index = PCH_NULL_INDEX;
    }
    index = PCH_FIRST_USER_INDEX;
    for( e = AuxList; e != NULL; e = e->next ) {
        if( e->info->index == PCH_NULL_INDEX ) {
            e->info->index = index++;
        }
    }
    PCHWriteUInt( index );
    for( e = AuxList; e != NULL; e = e->next ) {
        e->info->index = PCH_NULL_INDEX;
    }
    // write built-in aux_info
    for( index = PCH_FIRST_INDEX; index < PCH_FIRST_USER_INDEX; ++index ) {
        info = BuiltinAuxInfo + index - PCH_FIRST_INDEX;
        writeAuxInfo( info, index );
    }
    // write user aux_info
    for( e = AuxList; e != NULL; e = e->next ) {
        info = e->info;
        if( info->index == PCH_NULL_INDEX ) {
            writeAuxInfo( info, index++ );
        }
    }
    // write aux entries
    for( e = AuxList; e != NULL; e = e->next ) {
        len = strlen( e->name );
        PCHWriteUInt( len );
        PCHWrite( e->name, len + 1 );
        PCHWriteUInt( PCHGetUInt( PragmaGetIndex( e->info ) ) );
    }
    PCHWriteUInt( 0 );
    return( PCHCB_OK );
}
Пример #9
0
pch_status PCHWriteNames( void )
{
    unsigned len;
    int i;
    idname *name;
    idname **p;

    PCHWriteVar( nameCount );
    PCHWriteVar( nameDummyIndex );
    p = nameTranslateTable;
    for( i = 0; i < nameCount; ++i ) {
        name = *p++;
        len = strlen( name->name );
        DbgAssert( len != 0 );
        PCHWriteUInt( len );
        PCHWrite( &(name->xhash), NAME_SIZE_PCH + len + 1 );
    }
    PCHWriteUInt( 0 );
    return( PCHCB_OK );
}
Пример #10
0
static void writeExtrefs( void )
{
    unsigned        len;
    PRAG_EXT_REF    *e;

    RingIterBeg( pragmaExtrefs, e ) {
        if( e->symbol != NULL ) {
            SymbolPCHWrite( e->symbol );
        }
    } RingIterEnd( e )
    PCHWriteCVIndexTerm();
    RingIterBeg( pragmaExtrefs, e ) {
        if( e->symbol == NULL ) {
            len = strlen( e->name );
            PCHWriteUInt( len );
            PCHWrite( e->name, len + 1 );
        }
    } RingIterEnd( e )
    PCHWriteUInt( 0 );
}
Пример #11
0
void AsmSysPCHWriteCode( AUX_INFO *info )
/***************************************/
{
    BYTE_SEQ_SYM sym;
    byte_seq_len code_length;
    byte_seq_len seq_size;
    unsigned fixup;
    byte_seq *code;
    byte *d;
    byte *s;
    byte *c;
    byte *p;
    byte *tmp_buff;
#ifndef NDEBUG
    byte buff[8];
#else
    byte buff[1024];
#endif

    seq_size = 0;
    code = info->code;
    if( code == NULL ) {
        /* no code */
        PCHWriteUInt( seq_size );
        return;
    }
    code_length = code->length;
    seq_size = offsetof( byte_seq, data ) + code_length;
    PCHWriteUInt( seq_size );
    if( !code->relocs ) {
        /* code has no relocs */
        PCHWrite( code, seq_size );
        return;
    }
    /* code has relocs */
    tmp_buff = buff;
    if( seq_size > sizeof( buff ) ) {
        tmp_buff = CMemAlloc( seq_size );
    }
    c = code->data;
    s = code->data + code_length;
    d = copyCodeLen( tmp_buff, code, offsetof( byte_seq, data ) );
    for( p = c; p != s; ) {
        if( p[0] == FLOATING_FIXUP_BYTE ) {
            fixup = p[1];
            *d++ = *p++;
            *d++ = *p++;
            if( fixup != FLOATING_FIXUP_BYTE ) {
                switch( fixup ) {
                case FIX_SYM_OFFSET:
                case FIX_SYM_SEGMENT:
                case FIX_SYM_RELOFF:
                    sym = SymbolGetIndex( *((BYTE_SEQ_SYM *)p) );
                    d = copyCodeLen( d, &sym, sizeof( sym ) );
                    p += sizeof( BYTE_SEQ_SYM );
                    d = copyCodeLen( d, p, sizeof( BYTE_SEQ_OFF ) );
                    p += sizeof( BYTE_SEQ_OFF );
                    break;
                default:
                    break;
                }
            }
        } else {
            *d++ = *p++;
        }
    }
    PCHWrite( tmp_buff, seq_size );
    if( tmp_buff != buff ) {
        CMemFree( tmp_buff );
    }
}