Changeset 258 in dev
- Timestamp:
- Aug 2, 2007, 11:23:36 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r256 r258 551 551 552 552 trace( "コード生成が終了しました。" ); 553 554 vector<ObjectModule *> masterObjectModules; 555 masterObjectModules.push_back( &compiler.objectModule ); 556 //compiler.linker.Link( masterObjectModules ); 553 557 554 558 … … 1221 1225 delete pobj_GlobalVarSchedule; 1222 1226 1227 /* 1228 compiler.linker.SetImageBase( ImageBase ); 1229 compiler.linker.ResolveDataTableSchedules( MemPos_DataSection ); 1230 compiler.linker.ResolveDllProcSchedules( MemPos_CodeSection, MemPos_ImportSection, LookupSize, HintSize ); 1231 compiler.linker.ResolveUserProcSchedules( MemPos_CodeSection ); 1232 compiler.linker.ResolveDataTableSchedules( MemPos_RWSection ); 1233 */ 1223 1234 1224 1235 -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r255 r258 459 459 void PutOld( const NativeCode &nativeCode ) 460 460 { 461 pNativeCode->Put( nativeCode );461 pNativeCode->Put( nativeCode, true ); 462 462 } 463 463 void PutOld( char c ) -
trunk/abdev/BasicCompiler_Common/include/Linker.h
r257 r258 32 32 class Linker 33 33 { 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 46 34 NativeCode nativeCode; 47 48 35 DWORD imageBase; 49 36 50 37 public: 38 51 39 Linker() 52 40 { … … 58 46 } 59 47 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 60 60 // リンク 61 61 void Link( vector<ObjectModule *> &objectModules ); -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r257 r258 50 50 { 51 51 } 52 Schedule( Type type, long offset )52 Schedule( Type type, long offset, LONG_PTR lpValue = 0 ) 53 53 : type( type ) 54 54 , offset( offset ) 55 , lpValue( 0)56 { 57 } 58 Schedule( const ::UserProc *pUserProc, long off est )55 , lpValue( lpValue ) 56 { 57 } 58 Schedule( const ::UserProc *pUserProc, long offset ) 59 59 : type( Schedule::UserProc ) 60 60 , offset( offset ) … … 62 62 { 63 63 } 64 Schedule( const ::DllProc *pDllProc, long off est )64 Schedule( const ::DllProc *pDllProc, long offset ) 65 65 : type( Schedule::DllProc ) 66 66 , offset( offset ) … … 80 80 return offset; 81 81 } 82 LONG_PTR GetLongPtrValue() const 83 { 84 return lpValue; 85 } 82 86 const ::DllProc &GetDllProc() const 83 87 { … … 90 94 const ::UserProc &GetUserProc() const 91 95 { 92 if( type != Schedule::UserProc)96 if( !( type == Schedule::UserProc || type == Schedule::AddressOf ) ) 93 97 { 94 98 SetError(); … … 181 185 { 182 186 } 183 NativeCode( const NativeCode &nativeCode )187 NativeCode( const NativeCode &nativeCode, bool isOpBuffer ) 184 188 : allocateSize( 8192 ) 185 189 , codeBuffer( (char *)malloc( allocateSize ) ) 186 190 , size( 0 ) 187 191 { 188 Put( nativeCode );192 Put( nativeCode, isOpBuffer ); 189 193 } 190 194 NativeCode( const char *codeBuffer, int size ) … … 207 211 { 208 212 Clear(); 209 Put( nativeCode );213 Put( nativeCode, false ); 210 214 } 211 215 … … 250 254 } 251 255 252 void Put( const char *codeBuffer, int size )256 void Put( const char *codeBuffer, int size, bool isOpBuffer = true ) 253 257 { 254 258 Realloc( this->size + size ); … … 258 262 259 263 // 未完成 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 ); 266 273 void Put( _int64 i64data ) 267 274 { -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r257 r258 20 20 21 21 // DLL関数スケジュール 22 void Linker::ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset )22 void Linker::ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset, long lookupSize, long hintSize ) 23 23 { 24 24 BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() ) … … 33 33 ); 34 34 #else 35 // TODO: 未完成 36 SetError(); 35 nativeCode.Overwrite( 36 schedule.GetOffset(), 37 static_cast<long>( imageBase + importSectionBaseOffset + lookupSize + hintSize 38 + schedule.GetDllProc().GetLookupAddress() ) 39 ); 37 40 #endif 38 41 } … … 106 109 ObjectModule &masterObjectModule = *objectModules[0]; 107 110 108 nativeCode.Put( masterObjectModule.globalNativeCode );111 nativeCode.Put( masterObjectModule.globalNativeCode, false ); 109 112 110 113 masterObjectModule.meta.GetUserProcs().Iterator_Reset(); … … 117 120 pUserProc->SetBeginOpAddress( nativeCode.GetSize() ); 118 121 119 nativeCode.Put( pUserProc->GetNativeCode() );122 nativeCode.Put( pUserProc->GetNativeCode(), false ); 120 123 121 124 pUserProc->SetEndOpAddress( nativeCode.GetSize() ); -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r257 r258 18 18 } 19 19 20 void NativeCode::Put( const NativeCode &nativeCode )20 void NativeCode::Put( const NativeCode &nativeCode, bool isOpBuffer ) 21 21 { 22 22 long baseOffset = size; 23 23 24 Put( nativeCode.codeBuffer, nativeCode.size );24 Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer ); 25 25 26 26 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules ) … … 29 29 Schedule( 30 30 schedule.GetType(), 31 baseOffset + schedule.GetOffset() 31 baseOffset + schedule.GetOffset(), 32 schedule.GetLongPtrValue() 32 33 ) 33 34 );
Note:
See TracChangeset
for help on using the changeset viewer.