MCPcopy Create free account
hub / github.com/beefytech/Beef / FinishSymRecords

Method FinishSymRecords

IDEHelper/Linker/BlCodeView.cpp:998–1061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

996}
997
998void BlCodeView::FinishSymRecords()
999{
1000 BP_ZONE("BlCodeView::FinishSymRecords");
1001
1002 BlCvStreamReader reader;
1003 reader.mMsf = &mMsf;
1004 reader.Open(mStreams[mSymRecordsStream]);
1005
1006 auto itr = mSymRecordDeferredPositions.begin();
1007 auto endItr = mSymRecordDeferredPositions.end();
1008
1009 int wantPos = mSymRecordsWriter.GetStreamPos();
1010 int curPos = 0;
1011 while (itr != endItr)
1012 {
1013 int wantOfs = *itr;
1014 reader.Seek(wantOfs - curPos);
1015 curPos = wantOfs;
1016
1017 int16 hdrBuf[2];
1018 int16* hdr = (int16*)reader.ReadFast(&hdrBuf, 4);
1019 int16 symLen = hdr[0];
1020 int16 symType = hdr[1];
1021
1022 int wantSeekBytes = symLen - 2;
1023
1024 int addrOfs;
1025 switch (symType)
1026 {
1027 case S_LPROC32:
1028 case S_GPROC32:
1029 addrOfs = offsetof(PROCSYM32, off);
1030 break;
1031 case S_LTHREAD32:
1032 case S_GTHREAD32:
1033 addrOfs = offsetof(THREADSYM32, off);
1034 break;
1035 case S_LDATA32:
1036 case S_GDATA32:
1037 addrOfs = offsetof(DATASYM32, off);
1038 break;
1039 default:
1040 NotImpl();
1041 break;
1042 }
1043
1044 reader.Seek(addrOfs - 4);
1045 int32* ofsPtr = (int32*)reader.ReadFast(NULL, 4);
1046 int16* segPtr = (int16*)reader.ReadFast(NULL, 2);
1047
1048 auto segment = mContext->mSegments[*segPtr];
1049 auto outSection = mContext->mOutSections[segment->mOutSectionIdx];
1050 *ofsPtr += segment->mRVA - outSection->mRVA;
1051 *segPtr = outSection->mIdx + 1;
1052
1053 reader.Seek(wantSeekBytes - addrOfs - 2);
1054 curPos += 2 + symLen;
1055

Callers

nothing calls this directly

Calls 7

ReadFastMethod · 0.80
OpenMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetStreamPosMethod · 0.45
SeekMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected