📄 cv.c
字号:
EndIf
}
blocklevel++ ;
break ;
When S_LABEL32:
{
LABELSYM32 *p = align_copy ;
GlobalAddress(mod,&p->off, &p->seg) ;
copy_to_global = False ;
}
break ;
When S_RETURN:
memcpy(global_copy,align_copy,(*(bit_16_ptr)symptr) + 2) ;
break ;
When S_COMPILE:
copy_to_global = False ;
break ;
When S_OBJNAME:
copy_to_global = False ;
break ;
Otherwise:
printf("CV - unknown symbol record\n") ;
EndCase
length = (*(bit_16 *)symptr) + 2 ;
If copy_to_global IsTrue
Then
If global_len + length > global_max
Then
global_max += 65536 ;
oldptr_global = global_ptr ;
global_ptr = (byte_ptr) reallocate_memory(global_ptr, global_max) ;
If nextptr_global IsNotNull
Then
nextptr_global = (bit_32_ptr)((bit_32)nextptr_global + (bit_32)global_ptr - (bit_32) oldptr_global) ;
EndIf
If search_ptr_global IsNotNull
Then
search_ptr_global = (bit_32_ptr)((bit_32)search_ptr_global + (bit_32)global_ptr - (bit_32) oldptr_global) ;
EndIf
EndIf
memcpy(global_ptr + global_len, global_copy, length) ;
global_len += length ;
EndIf
memcpy(align_ptr + align_len, align_copy, length) ;
align_len += length ;
symptr += length ;
symlen -= length ;
EndWhile
EndIf
Mod.align_len = align_len ;
EndFor
*globallen = global_len ;
*globals = global_ptr ;
EndCode
#undef Mod
#undef Pub
#undef Lseg
#undef Lab
void create_codeview_data(byte_ptr *data_ptr, bit_32_ptr data_len)
BeginDeclarations
bit_32 i, j ;
byte_ptr globals ;
bit_32 global_len ;
byte_ptr linnum_ptr ;
module_ptr mod ;
#define Mod (*mod)
byte_ptr types ;
bit_32 type_len ;
byte_ptr types_offsets ;
bit_32 types_offsets_len ;
byte_ptr tables_ptr ;
bit_32 tables_size ;
byte_ptr dir_ptr ;
bit_32 dir_size ;
byte_ptr data ;
EndDeclarations
BeginCode
cv_globaltypes_data(&types, &type_len, &types_offsets, &types_offsets_len);
cv_globalsyms_data( & globals, & global_len);
tables_size = sizeof(OMFSignature) +32 ;
if (global_len)
tables_size += global_len + sizeof(OMFSymHash) ;
if (type_len)
tables_size += type_len + sizeof(OMFGlobalTypes) - sizeof(bit_32)
+ types_offsets_len ;
dir_size = sizeof(OMFDirHeader) ;
if (type_len)
dir_size += sizeof(OMFDirEntry);
if (global_len)
dir_size += sizeof(OMFDirEntry);
For i =0; i < n_modules; i++
BeginFor
mod = modules[i] ;
If Mod.debsymseg IsNotNull Or Mod.publics.first IsNotNull
Then
dir_size+= sizeof(OMFDirEntry) ; /* module entry */
tables_size += sizeof(OMFModule) - sizeof(OMFSegDesc);
If Mod.cseg AndIf Mod.cseg->length
Then
tables_size += sizeof(OMFSegDesc) ;
EndIf
If Mod.dseg AndIf Mod.dseg->length
Then
tables_size += sizeof(OMFSegDesc) ;
EndIf
If Mod.bseg AndIf Mod.bseg->length
Then
tables_size += sizeof(OMFSegDesc) ;
EndIf
tables_size += strlen(Mod.name) ;
tables_size = (tables_size + 3) & ~3 ;
If Mod.align_len IsNotZero
Then
dir_size+= sizeof(OMFDirEntry) ; /* align entry */
tables_size += Mod.align_len ;
EndIf
If Mod.linnum_len IsNotZero
Then
dir_size+= sizeof(OMFDirEntry) ; /* linnum entry */
tables_size += Mod.linnum_len + sizeof(bit_32);
tables_size = (tables_size + 3) & ~3 ;
EndIf
EndIf
EndFor
data = (byte_ptr) allocate_memory(dir_size + tables_size) ;
tables_ptr = data + 32;
dir_ptr = data + tables_size ;
{
OMFSignature *p = tables_ptr ;
p->Signature[0] = 'L' ;
p->Signature[1] = 'S' ;
p->Signature[2] = '1' ;
p->Signature[3] = '1' ;
p->filepos = tables_size - 32 ;
tables_ptr += sizeof(OMFSignature) ;
}
{
OMFDirHeader *p = dir_ptr ;
p->cbDirHeader = sizeof(OMFDirHeader) ;
p->cbDirEntry = sizeof(OMFDirEntry) ;
p->cDir = (dir_size - sizeof(OMFDirHeader)) / sizeof(OMFDirEntry) ;
p->lfoNextDir = 0 ;
p->flags = 0 ;
dir_ptr += sizeof(OMFDirHeader) ;
}
For i = 0 ; i < n_modules; i++
BeginFor
OMFModule *m = tables_ptr ;
OMFSegDesc *p ;
mod = modules[i] ;
If Mod.debsymseg IsNotNull Or Mod.publics.first IsNotNull
Then
m->ovlNumber = 0 ;
m->iLib = 0 ;
m->cSeg = 0 ;
m->Style[0] = 'C' ;
m->Style[1] = 'V' ;
p = &m->SegInfo ;
If Mod.cseg IsNotZero AndIf Mod.cseg->length IsNotZero
Then
p->Seg = 1 ;
p->pad = 0 ;
p->Off = 0 ;
p->cbSeg = Mod.cseg->length ;
GlobalAddress(mod, &p->Off, &p->Seg) ;
m->cSeg++ ;
p ++ ;
EndIf
If Mod.dseg IsNotZero AndIf Mod.dseg->length IsNotZero
Then
p->Seg = 2 ;
p->pad = 0 ;
p->Off = 0 ;
p->cbSeg = Mod.dseg->length ;
GlobalAddress(mod, &p->Off, &p->Seg) ;
m->cSeg++ ;
p ++ ;
EndIf
If Mod.bseg IsNotZero AndIf Mod.bseg->length IsNotZero
Then
p->Seg = 3 ;
p->pad = 0 ;
p->Off = 0 ;
p->cbSeg = Mod.bseg->length ;
GlobalAddress(mod, &p->Off, &p->Seg) ;
m->cSeg++ ;
p ++ ;
EndIf
*(byte_ptr)p = strlen(Mod.name) ;
memcpy(((byte_ptr)p)+1,Mod.name, *(byte_ptr)p) ;
(byte_ptr)p += 1 + *(byte_ptr)p ;
If (((byte_ptr)p - tables_ptr) And 3) IsNotZero
Then
(byte_ptr)p += 4 - (((byte_ptr)p -tables_ptr) And 3) ;
EndIf
{
OMFDirEntry * q = dir_ptr ;
q->SubSection = sstModule ;
q->iMod = i + 1 ;
q->lfo = tables_ptr - data - 32 ;
q->cb = (byte_ptr)p - (byte_ptr)tables_ptr ;
dir_ptr += sizeof(OMFDirEntry);
}
tables_ptr = (byte_ptr) p ;
EndIf
EndFor
For i = 0; i < n_modules; i++
BeginFor
mod = modules[i] ;
If Mod.debsymseg IsNotNull Or Mod.publics.first IsNotNull
Then
If Mod.align_len IsNotZero
Then
memcpy(tables_ptr,Mod.align_data,Mod.align_len) ;
{
OMFDirEntry *p = dir_ptr ;
p->SubSection = sstAlignSym ;
p->iMod = i + 1 ;
p->lfo = tables_ptr - data - 32;
p->cb = Mod.align_len ;
dir_ptr += sizeof(OMFDirEntry) ;
}
tables_ptr += Mod.align_len ;
EndIf
If Mod.linnum_len
Then
linnum_ptr = tables_ptr + sizeof(bit_16);
*((bit_16_ptr)linnum_ptr)++ = Mod.linnum_len / 6 ;
For j = 0 ; j < Mod.linnum_len; j += 6
BeginFor
(*(bit_16_ptr)tables_ptr) = 1 ;
*(bit_32 *)linnum_ptr = *(bit_32_ptr) (Mod.linnum_data + j + sizeof(bit_16)) ;
GlobalAddress(mod,linnum_ptr, tables_ptr) ;
linnum_ptr += sizeof(bit_32) ;
EndFor
For j = 0; j < Mod.linnum_len; j+= 6
BeginFor
*((bit_16_ptr)linnum_ptr)++ = *(bit_16_ptr) (Mod.linnum_data + j) ;
EndFor
{
OMFDirEntry *p = dir_ptr ;
p->SubSection = sstSrcModule ;
p->iMod = i + 1 ;
p->lfo = tables_ptr - data - 32 ;
p->cb = (byte_ptr)linnum_ptr - (byte_ptr)tables_ptr ;
dir_ptr += sizeof(OMFDirEntry) ;
}
tables_ptr = linnum_ptr ;
If (tables_ptr - data ) And 3
Then
tables_ptr += 4 - ((tables_ptr - data) And 3) ;
EndIf
EndIf
EndIf
EndFor
{
OMFSymHash *p = tables_ptr ;
p->symhash = OMFHASH_NONE ;
p->addrhash = OMFHASH_NONE ;
p->cbSymbol = global_len ;
p->cbHSym = 0;
p->cbHAddr = 0 ;
memcpy(tables_ptr + sizeof(OMFSymHash), globals, global_len) ;
{
OMFDirEntry *p = dir_ptr ;
p->SubSection = sstGlobalSym ;
p->iMod = 0xffff ;
p->lfo = tables_ptr - data - 32 ;
p->cb = global_len + sizeof(OMFSymHash) ;
dir_ptr += sizeof(OMFDirEntry) ;
}
tables_ptr += global_len + sizeof(OMFSymHash) ;
}
If type_len GreaterThan 0
Then
OMFGlobalTypes *p = tables_ptr ;
p->flags.sig = 0xa4 ; /* wasn't specified */
p->cTypes = types_offsets_len / sizeof(bit_32) ;
memcpy(p->typeOffset,types_offsets, types_offsets_len) ;
memcpy((byte_ptr)p->typeOffset + types_offsets_len,types, type_len) ;
{
OMFDirEntry *p = dir_ptr ;
p->SubSection = sstGlobalTypes ;
p->iMod = 0xffff ;
p->lfo = tables_ptr - data - 32 ;
p->cb = sizeof(OMFGlobalTypes) - sizeof(bit_32) + types_offsets_len + type_len ;
dir_ptr += sizeof(OMFDirEntry) ;
tables_ptr += p->cb ;
}
EndIf
If tables_ptr - data IsNotEqualTo tables_size
Then
printf("CV - module data mismatch") ;
EndIf
If dir_ptr - data IsNotEqualTo tables_size + dir_size
Then
printf("CV - dir entry mismatch") ;
EndIf
*data_ptr = data ;
*data_len = tables_size + dir_size ;
EndCode
#undef Mod
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -