static fe_seg_id cgSegIdHugeVariable( SYMBOL sym, type_flag flags, target_size_t size, SEGID_CONTROL control ) { fe_seg_id id; if( SymIsExtern( sym ) ) { id = SegmentImport(); } else if( cgSegIdConst( sym, flags, control ) ) { id = SegmentAddConstHuge( size ); } else { id = SegmentAddHuge( size ); } return( id ); }
static fe_seg_id cgSegIdFarVariable( SYMBOL sym, type_flag flags, target_size_t size, SEGID_CONTROL control ) { fe_seg_id id; target_offset_t align; align = cgSegIdAlign( sym, flags ); if( SymIsExtern( sym ) ) { // not defined in this compilation unit id = SegmentImport(); } else if( !cgSegIdConst( sym, flags, control ) ) { id = SegmentAddFar( size, align ); } else { id = SegmentAddConstFar( size, align ); } return( id ); }
static fe_seg_id cgSegIdBased( SYMBOL sym, type_flag flags ) { fe_seg_id id; // - segment id target_offset_t align; // - alignment for symbol target_size_t size; // - size of symbol TYPE base_mod; // - __based modifier size = CgMemorySize( sym->sym_type ); #ifdef _CHECK_SIZE // only defined if needed if( !(flags & TF1_HUGE) ) { if( _CHECK_SIZE( size ) ) { CErr2p( ERR_DATA_TOO_BIG, sym ); return( SEG_NULL ); } } #endif if( SymIsExtern( sym ) ) { // not defined in this compilation unit id = SegmentImport(); } else { switch( flags & TF1_BASED ) { case TF1_BASED_STRING: id = SegmentFindBased( sym->sym_type ); break; case TF1_BASED_SELF: case TF1_BASED_VOID: id = SEG_NULL; break; case TF1_BASED_FETCH: case TF1_BASED_ADD: base_mod = BasedType( sym->sym_type ); id = CgSegIdData( (SYMBOL)base_mod->u.m.base, SI_DEFAULT ); break; DbgDefault( "invalid based cgsegid call" ); } if( id != SEG_NULL ) { align = cgSegIdAlign( sym, flags ); id = SegmentAddSym( sym, id, size, align ); } } return( id ); }
void PragmaExtrefsValidate // VALIDATE EXTREFS FOR PRAGMAS ( void ) { PRAG_EXT_REF* entry; // - current entry RingIterBeg( pragmaExtrefs, entry ) { if( entry->symbol != NULL ) { SYMBOL symbol = entry->symbol; if( SymIsExtern( symbol ) ) { if( IsOverloadedFunc( symbol ) ) { CErr2p( ERR_PRAG_EXTREF_OVERLOADED, symbol ); entry->symbol = NULL; } } else { CErr2p( ERR_PRAG_EXTREF_EXTERN, symbol ); entry->symbol = NULL; } } } RingIterEnd( entry ); }
static fe_seg_id cgSegIdNearVariable( SYMBOL sym, type_flag flags, target_size_t size, SEGID_CONTROL control ) { fe_seg_id id; target_offset_t align; align = cgSegIdAlign( sym, flags ); if( SymIsExtern( sym ) ) { // somewhere in DGROUP (SEG_BSS,SEG_DATA,SEG_CONST2,SEG_STACK) // decision about NEAR/FAR done in cgSegIdVariable id = SegmentAddSym( sym, SEG_DATA, size, align ); } else if( control & SI_ALL_ZERO ) { // defined to be zero in this compilation unit id = SegmentAddSym( sym, SEG_BSS, size, align ); } else if( !cgSegIdConst( sym, flags, control ) ) { id = SegmentAddSym( sym, SEG_DATA, size, align ); } else { id = SegmentAddSym( sym, SEG_CONST2, size, align ); } return( id ); }
static fe_seg_id cgSegIdThread( SYMBOL sym, type_flag flags ) { fe_seg_id id; // - segment id flags = flags; #ifdef _CHECK_SIZE // only defined if needed if( !(flags & TF1_HUGE) ) { target_size_t size; // - size of symbol size = CgMemorySize( sym->sym_type ); if( _CHECK_SIZE( size ) ) { CErr2p( ERR_DATA_TOO_BIG, sym ); return( SEG_NULL ); } } #endif if( SymIsExtern( sym ) ) { // not defined in this compilation unit id = SegmentImport(); } else { id = SEG_TLS; } return( id ); }
fe_seg_id SegmentAddSym( // SEGMENT: ADD SYMBOL TO SPECIFIED SEGMENT SYMBOL sym, // - sym to add fe_seg_id id, // - id of segment to use target_size_t size, // - size of sym target_offset_t align ) // - alignment for sym { PC_SEGMENT *curr; // - new segment target_size_t aligned_offset; target_size_t calc_offset; target_size_t total_size; if( id == SEG_DATA || ( id == SEG_BSS && flags.use_def_seg ) ) { curr = data_def_seg.pcseg; id = curr->seg_id; } else if( id == SEG_CODE ) { curr = code_def_seg.pcseg; id = curr->seg_id; } else { curr = segIdLookup( id ); } if( curr == NULL ) { CFatal( "segment: cannot find default segment" ); } else { accumAlignment( curr, align ); if( ( ! SymIsInitialized( sym ) ) && SymIsExtern( sym ) ) { id = curr->seg_id; _markUsed( curr, TRUE ); curr->has_data = TRUE; data_def_seg.ds_used = TRUE; } else { aligned_offset = SegmentAdjust( curr->seg_id, curr->offset, align ); calc_offset = curr->offset + aligned_offset + size; _CHECK_ADJUST( calc_offset, calc_offset, curr->offset ); if( calc_offset == 0 ) { if( size != 0 ) { CErr( ERR_MAX_SEGMENT_EXCEEDED, curr->name, sym ); } id = SEG_NULL; } else if( curr->dgroup ) { total_size = dgroup_size + size + aligned_offset; _CHECK_ADJUST( calc_offset, total_size, dgroup_size ); if( calc_offset == 0 ) { if( size != 0 ) { CErr( ERR_MAX_DGROUP_EXCEEDED, sym, curr->name ); } id = SEG_NULL; } else { dgroup_size += size + aligned_offset; curr->offset = calc_offset; _markUsed( curr, TRUE ); curr->has_data = TRUE; id = curr->seg_id; data_def_seg.ds_used = TRUE; } } else { curr->offset = calc_offset; _markUsed( curr, TRUE ); curr->has_data = TRUE; id = curr->seg_id; data_def_seg.ds_used = TRUE; } } } return id; }