Changeset 258 in dev for trunk/abdev/BasicCompiler_Common


Ignore:
Timestamp:
Aug 2, 2007, 11:23:36 PM (17 years ago)
Author:
dai_9181
Message:

Linkerの骨格を作成した

Location:
trunk/abdev/BasicCompiler_Common
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h

    r255 r258  
    459459    void PutOld( const NativeCode &nativeCode )
    460460    {
    461         pNativeCode->Put( nativeCode );
     461        pNativeCode->Put( nativeCode, true );
    462462    }
    463463    void PutOld( char c )
  • trunk/abdev/BasicCompiler_Common/include/Linker.h

    r257 r258  
    3232class Linker
    3333{
    34     // データテーブルスケジュール
    35     void ResolveDataTableSchedules( long dataSectionBaseOffset );
    36 
    37     // DLL関数スケジュール
    38     void ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset );
    39 
    40     // ユーザ定義関数スケジュール
    41     void ResolveUserProcSchedules( long codeSectionBaseOffset );
    42 
    43     // グローバル変数スケジュール
    44     void ResolveGlobalVarSchedules( long rwSectionBaseOffset );
    45 
    4634    NativeCode nativeCode;
    47 
    4835    DWORD imageBase;
    4936
    5037public:
     38
    5139    Linker()
    5240    {
     
    5846    }
    5947
     48    // データテーブルスケジュール
     49    void ResolveDataTableSchedules( long dataSectionBaseOffset );
     50
     51    // DLL関数スケジュール
     52    void ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset, long lookupSize, long hintSize );
     53
     54    // ユーザ定義関数スケジュール
     55    void ResolveUserProcSchedules( long codeSectionBaseOffset );
     56
     57    // グローバル変数スケジュール
     58    void ResolveGlobalVarSchedules( long rwSectionBaseOffset );
     59
    6060    // リンク
    6161    void Link( vector<ObjectModule *> &objectModules );
  • trunk/abdev/BasicCompiler_Common/include/NativeCode.h

    r257 r258  
    5050    {
    5151    }
    52     Schedule( Type type, long offset )
     52    Schedule( Type type, long offset, LONG_PTR lpValue = 0 )
    5353        : type( type )
    5454        , offset( offset )
    55         , lpValue( 0 )
    56     {
    57     }
    58     Schedule( const ::UserProc *pUserProc, long offest )
     55        , lpValue( lpValue )
     56    {
     57    }
     58    Schedule( const ::UserProc *pUserProc, long offset )
    5959        : type( Schedule::UserProc )
    6060        , offset( offset )
     
    6262    {
    6363    }
    64     Schedule( const ::DllProc *pDllProc, long offest )
     64    Schedule( const ::DllProc *pDllProc, long offset )
    6565        : type( Schedule::DllProc )
    6666        , offset( offset )
     
    8080        return offset;
    8181    }
     82    LONG_PTR GetLongPtrValue() const
     83    {
     84        return lpValue;
     85    }
    8286    const ::DllProc &GetDllProc() const
    8387    {
     
    9094    const ::UserProc &GetUserProc() const
    9195    {
    92         if( type != Schedule::UserProc )
     96        if( !( type == Schedule::UserProc || type == Schedule::AddressOf ) )
    9397        {
    9498            SetError();
     
    181185    {
    182186    }
    183     NativeCode( const NativeCode &nativeCode )
     187    NativeCode( const NativeCode &nativeCode, bool isOpBuffer )
    184188        : allocateSize( 8192 )
    185189        , codeBuffer( (char *)malloc( allocateSize ) )
    186190        , size( 0 )
    187191    {
    188         Put( nativeCode );
     192        Put( nativeCode, isOpBuffer );
    189193    }
    190194    NativeCode( const char *codeBuffer, int size )
     
    207211    {
    208212        Clear();
    209         Put( nativeCode );
     213        Put( nativeCode, false );
    210214    }
    211215
     
    250254    }
    251255
    252     void Put( const char *codeBuffer, int size )
     256    void Put( const char *codeBuffer, int size, bool isOpBuffer = true )
    253257    {
    254258        Realloc( this->size + size );
     
    258262
    259263        // 未完成
    260         extern char *OpBuffer;
    261         extern int obp;
    262         memcpy( OpBuffer + obp, codeBuffer, size );
    263         ObpPlus( size );
    264     }
    265     void Put( const NativeCode &nativeCode );
     264        if( isOpBuffer )
     265        {
     266            extern char *OpBuffer;
     267            extern int obp;
     268            memcpy( OpBuffer + obp, codeBuffer, size );
     269            ObpPlus( size );
     270        }
     271    }
     272    void Put( const NativeCode &nativeCode, bool isOpBuffer );
    266273    void Put( _int64 i64data )
    267274    {
  • trunk/abdev/BasicCompiler_Common/src/Linker.cpp

    r257 r258  
    2020
    2121// DLL関数スケジュール
    22 void Linker::ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset )
     22void Linker::ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset, long lookupSize, long hintSize )
    2323{
    2424    BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() )
     
    3333            );
    3434#else
    35             // TODO: 未完成
    36             SetError();
     35            nativeCode.Overwrite(
     36                schedule.GetOffset(),
     37                static_cast<long>( imageBase + importSectionBaseOffset + lookupSize + hintSize
     38                    + schedule.GetDllProc().GetLookupAddress() )
     39            );
    3740#endif
    3841        }
     
    106109    ObjectModule &masterObjectModule = *objectModules[0];
    107110
    108     nativeCode.Put( masterObjectModule.globalNativeCode );
     111    nativeCode.Put( masterObjectModule.globalNativeCode, false );
    109112
    110113    masterObjectModule.meta.GetUserProcs().Iterator_Reset();
     
    117120            pUserProc->SetBeginOpAddress( nativeCode.GetSize() );
    118121
    119             nativeCode.Put( pUserProc->GetNativeCode() );
     122            nativeCode.Put( pUserProc->GetNativeCode(), false );
    120123
    121124            pUserProc->SetEndOpAddress( nativeCode.GetSize() );
  • trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp

    r257 r258  
    1818}
    1919
    20 void NativeCode::Put( const NativeCode &nativeCode )
     20void NativeCode::Put( const NativeCode &nativeCode, bool isOpBuffer )
    2121{
    2222    long baseOffset = size;
    2323
    24     Put( nativeCode.codeBuffer, nativeCode.size );
     24    Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer );
    2525
    2626    BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
     
    2929            Schedule(
    3030                schedule.GetType(),
    31                 baseOffset + schedule.GetOffset()
     31                baseOffset + schedule.GetOffset(),
     32                schedule.GetLongPtrValue()
    3233            )
    3334        );
Note: See TracChangeset for help on using the changeset viewer.