示例#1
0
void SstGlobalSym::Put( ExeMaker& eMaker, const uint cSeg )
/***************************************************************/
{
    if ( _symbolInfo.isEmpty() ) {
        eMaker.DumpToExe( (unsigned_16) 0 );
        eMaker.DumpToExe( (unsigned_16) 0 );
        eMaker.DumpToExe( (unsigned_32) 0 );
        eMaker.DumpToExe( (unsigned_32) 0 );
        eMaker.DumpToExe( (unsigned_32) 0 );
        return;
    }
    unsigned_32 currentOffset = 0;
    /*
    cerr << "entered SstGlobalSym::Put()\n";
    cerr << "creating nameHash for ";
    cerr << _symbolInfo.entries();
    cerr << " symbols.\n";
    cerr.flush();
    */
    eMaker.DumpToExe( (unsigned_16) DEFAULT_NAME_HASH );
    eMaker.DumpToExe( (unsigned_16) DEFAULT_ADDR_HASH );
    streampos pos = eMaker.TellPos();
    eMaker.Reserve(3*LONG_WORD);
    NameHashTable nameHash(_symbolInfo.entries());
    /*
    cerr << "NameHashTable complete\n";
    cerr.flush();
    */
    AddrHashTable addrHash(cSeg);
    /*
    cerr << "AddrHashTable complete\n";
    cerr.flush();
    */

    //WCPtrConstSListIter<SymbolStruct> iter(_symbolInfo);
    SymbolStruct* currentPtr = NULL;
    long cnt=0, mcnt;
    mcnt = _symbolInfo.entries();
    /*
    cerr << "_symbolInfo has ";
    cerr << mcnt;
    cerr << " entries.\n";
    cerr.flush();
    */
    //while ( ++iter ) {
    while ( cnt++ < mcnt) {
        /*
        cerr << "global Symbol count: ";
        cerr << cnt;
        cerr << "\n";
        cerr.flush();
        */
        //currentPtr = iter.current();
        currentPtr = _symbolInfo.get(cnt);

        //cerr << "OK\n";
        //cerr.flush();

        currentPtr -> SetOffset(currentOffset);
        if ( currentPtr -> cSum() == NO_CHKSUM ) {
            if ( addrHash.TryToInsert(currentPtr) ) {
                currentOffset += SymbolSubsection::PageAlign(eMaker,currentPtr->Length(),currentOffset);
                currentOffset += currentPtr -> Length();
                currentPtr -> Put(eMaker);
            }
        } else if ( nameHash.TryToInsert(currentPtr) ) {
                currentOffset += SymbolSubsection::PageAlign(eMaker,currentPtr->Length(),currentOffset);
                currentOffset += currentPtr -> Length();
                currentPtr -> Put(eMaker);
                addrHash.TryToInsert(currentPtr);
        }
    }
    currentOffset += SymbolSubsection::DumpPageAlign(eMaker,LONG_WORD,0xff);
    unsigned_32 preNameHasPos = eMaker.TellPos();
    nameHash.Put(eMaker);
    unsigned_32 suNameHasPos = eMaker.TellPos();
    addrHash.Put(eMaker);
    unsigned_32 currentPos = eMaker.TellPos();
    eMaker.SeekTo(pos);
    eMaker.DumpToExe(currentOffset);
    eMaker.DumpToExe(suNameHasPos - preNameHasPos);
    eMaker.DumpToExe(currentPos - suNameHasPos);
    eMaker.SeekTo(currentPos);
}