static void DumpHeader(void* D) { DumpByte(ID_CHUNK,D); DumpSig(SIGNATURE, D); DumpByte(VERSION,D); DumpByte(luaU_endianess(),D); DumpByte(sizeof(int),D); DumpByte(sizeof(size_t),D); DumpByte(sizeof(Instruction),D); DumpByte(SIZE_INSTRUCTION,D); DumpByte(SIZE_OP,D); DumpByte(SIZE_B,D); DumpByte(sizeof(Number),D); DumpNumber(TEST_NUMBER,D); }
void CVpack::DoDirectory() /************************/ { streampos dirOffset = OFBase(); unsigned_32 cvSize; _newDir.Put(_eMaker); DumpSig(); // compute lfoBase and dump it out. cvSize = (unsigned_32)(_eMaker.TellPos()+LONG_WORD-_lfaBase); _eMaker.DumpToExe(cvSize); _eMaker.SeekTo(_lfaBase+LONG_WORD); _eMaker.DumpToExe((unsigned_32)dirOffset); if (_ddeBase) { _eMaker.SeekTo(_ddeBase+0x10); // offset of debug_size field entry _eMaker.DumpToExe(cvSize); // write new segment size to PE debug dir entry } }
void CVpack::CreatePackExe() /**************************/ { uint moduleNum = 0; // number of segment received code from a module. uint moduleSeg = 0; DoExeCode(); DumpSig(); // reserve for directory offset. _eMaker.Reserve(LONG_WORD); moduleNum = DoSstModule(); SstGlobalTypes globalType; SstAlignSym* alignSym; SstGlobalSym globalSym; SstStaticSym staticSym; bool gottype, gotsrcmod; unsigned_32 length; char *buffer, *buffer2; SymbolDistributor symDis(_aRetriever, globalSym, staticSym); for ( uint module = 1; ; module++ ) { if( _aRetriever.IsAtSubsection( sstSegMap ) ) break; gottype = globalType.LoadTypes(_aRetriever,module); gotsrcmod = false; if ( _aRetriever.ReadSubsection(buffer,length,sstSrcModule,module) ) { moduleSeg = ( * (unsigned_16 *) (buffer + WORD) ); gotsrcmod = true; buffer2 = new char [length]; memcpy( buffer2, buffer, length ); } if( gottype ) { alignSym = new SstAlignSym(moduleSeg); if ( ! symDis.Distribute(module, *alignSym) ) { delete alignSym; break; } DoAlignSym(alignSym, module); delete alignSym; } if (gotsrcmod) { _newDir.Insert(sstSrcModule,module,OFBase(),length); _eMaker.DumpToExe(buffer2,length); delete buffer2; buffer2 = 0; } } uint cSeg = DoSegMap(); DoPublics(cSeg,moduleNum); //cerr << "finished DoPublics.\n"; cerr.flush(); DoGlobalSym(globalSym,cSeg); //cerr << "finished DoGlobalSym.\n"; cerr.flush(); DoLibraries(); //cerr << "finished DoLibraries.\n"; cerr.flush(); DoGlobalTypes(globalType); //cerr << "finished DoGlobalTypes.\n"; cerr.flush(); DoStaticSym(staticSym,cSeg); //cerr << "finished DoStaticSym.\n"; cerr.flush(); DoDirectory(); //cerr << "finished DoDirectory.\n"; cerr.flush(); _eMaker.Close(); //cerr << "finished CreatePackExe()\n"; cerr.flush(); }