More tabs replaced with spaces
This commit is contained in:
@@ -37,12 +37,12 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
{
|
||||
int i;
|
||||
int count = 0;
|
||||
int firstSym = 0; /* First symbol this module */
|
||||
int firstSym = 0; /* First symbol this module */
|
||||
uint8_t b, c, type;
|
||||
uint16_t w, len;
|
||||
|
||||
codeLNAMES = NONE; /* Invalidate indexes for code segment */
|
||||
codeSEGDEF = NONE; /* Else won't be assigned */
|
||||
codeLNAMES = NONE; /* Invalidate indexes for code segment */
|
||||
codeSEGDEF = NONE; /* Else won't be assigned */
|
||||
|
||||
offset = 0; /* For diagnostics, really */
|
||||
|
||||
@@ -61,7 +61,7 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
switch (type)
|
||||
{
|
||||
|
||||
case 0x96: /* LNAMES */
|
||||
case 0x96: /* LNAMES */
|
||||
while (len > 1)
|
||||
{
|
||||
readString(fl);
|
||||
@@ -73,11 +73,11 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
}
|
||||
len -= strlen((char *)buf)+1;
|
||||
}
|
||||
b = readByte(fl); /* Checksum */
|
||||
b = readByte(fl); /* Checksum */
|
||||
break;
|
||||
|
||||
case 0x98: /* Segment definition */
|
||||
b = readByte(fl); /* Segment attributes */
|
||||
case 0x98: /* Segment definition */
|
||||
b = readByte(fl); /* Segment attributes */
|
||||
if ((b & 0xE0) == 0)
|
||||
{
|
||||
/* Alignment field is zero. Frame and offset follow */
|
||||
@@ -85,25 +85,25 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
readByte(fl);
|
||||
}
|
||||
|
||||
w = readWord(fl); /* Segment length */
|
||||
w = readWord(fl); /* Segment length */
|
||||
|
||||
b = readByte(fl); /* Segment name index */
|
||||
b = readByte(fl); /* Segment name index */
|
||||
++segnum;
|
||||
|
||||
b = readByte(fl); /* Class name index */
|
||||
b = readByte(fl); /* Class name index */
|
||||
if ((b == codeLNAMES) and (codeSEGDEF == NONE))
|
||||
{
|
||||
/* This is the segment defining the code class */
|
||||
codeSEGDEF = segnum;
|
||||
}
|
||||
|
||||
b = readByte(fl); /* Overlay index */
|
||||
b = readByte(fl); /* Checksum */
|
||||
b = readByte(fl); /* Overlay index */
|
||||
b = readByte(fl); /* Checksum */
|
||||
break;
|
||||
|
||||
case 0x90: /* PUBDEF: public symbols */
|
||||
b = readByte(fl); /* Base group */
|
||||
c = readByte(fl); /* Base segment */
|
||||
case 0x90: /* PUBDEF: public symbols */
|
||||
b = readByte(fl); /* Base group */
|
||||
c = readByte(fl); /* Base segment */
|
||||
len -= 2;
|
||||
if (c == 0)
|
||||
{
|
||||
@@ -113,8 +113,8 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
while (len > 1)
|
||||
{
|
||||
readString(fl);
|
||||
w = readWord(fl); /* Offset */
|
||||
b = readByte(fl); /* Type index */
|
||||
w = readWord(fl); /* Offset */
|
||||
b = readByte(fl); /* Type index */
|
||||
if (c == codeSEGDEF)
|
||||
{
|
||||
char *p;
|
||||
@@ -122,7 +122,7 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
p = (char *)buf;
|
||||
if (buf[0] == '_') /* Leading underscore? */
|
||||
{
|
||||
p++; /* Yes, remove it*/
|
||||
p++; /* Yes, remove it*/
|
||||
}
|
||||
i = std::min(size_t(SYMLEN-1), strlen(p));
|
||||
memcpy(entry.name, p, i);
|
||||
@@ -134,21 +134,21 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
}
|
||||
len -= strlen((char *)buf) + 1 + 2 + 1;
|
||||
}
|
||||
b = readByte(fl); /* Checksum */
|
||||
b = readByte(fl); /* Checksum */
|
||||
break;
|
||||
|
||||
|
||||
case 0xA0: /* LEDATA */
|
||||
case 0xA0: /* LEDATA */
|
||||
{
|
||||
b = readByte(fl); /* Segment index */
|
||||
w = readWord(fl); /* Offset */
|
||||
b = readByte(fl); /* Segment index */
|
||||
w = readWord(fl); /* Offset */
|
||||
len -= 3;
|
||||
/*printf("LEDATA seg %d off %02X len %Xh, looking for %d\n", b, w, len-1, codeSEGDEF);//*/
|
||||
|
||||
if (b != codeSEGDEF)
|
||||
{
|
||||
readNN(len,fl); /* Skip the data */
|
||||
break; /* Next record */
|
||||
break; /* Next record */
|
||||
}
|
||||
|
||||
|
||||
@@ -160,12 +160,12 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
offset += len-1;
|
||||
maxLeData = std::max<uint16_t>(maxLeData, w+len-1);
|
||||
|
||||
readByte(fl); /* Checksum */
|
||||
readByte(fl); /* Checksum */
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
readNN(len,fl); /* Just skip the lot */
|
||||
readNN(len,fl); /* Just skip the lot */
|
||||
|
||||
if (type == 0x8A) /* Mod end */
|
||||
{
|
||||
@@ -176,7 +176,7 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
uint16_t off = keys[i].offset;
|
||||
if (off == (uint16_t)-1)
|
||||
{
|
||||
continue; /* Ignore if already done */
|
||||
continue; /* Ignore if already done */
|
||||
}
|
||||
if (keys[i].offset > maxLeData)
|
||||
{
|
||||
@@ -213,14 +213,14 @@ int LIB_PatternCollector::readSyms(FILE *fl)
|
||||
|
||||
|
||||
while (readByte(fl) == 0);
|
||||
readNN(-1,fl); /* Unget the last byte (= type) */
|
||||
lnum = 0; /* Reset index into lnames */
|
||||
segnum = 0; /* Reset index into snames */
|
||||
readNN(-1,fl); /* Unget the last byte (= type) */
|
||||
lnum = 0; /* Reset index into lnames */
|
||||
segnum = 0; /* Reset index into snames */
|
||||
firstSym = count; /* Remember index of first sym this mod */
|
||||
codeLNAMES = NONE; /* Invalidate indexes for code segment */
|
||||
codeSEGDEF = NONE;
|
||||
memset(leData, 0, maxLeData); /* Clear out old junk */
|
||||
maxLeData = 0; /* No data read this module */
|
||||
maxLeData = 0; /* No data read this module */
|
||||
}
|
||||
|
||||
else if (type == 0xF1)
|
||||
|
||||
@@ -6,15 +6,15 @@ struct LIB_PatternCollector : public PatternCollector
|
||||
{
|
||||
protected:
|
||||
unsigned long offset;
|
||||
uint8_t lnum = 0; /* Count of LNAMES so far */
|
||||
uint8_t segnum = 0; /* Count of SEGDEFs so far */
|
||||
uint8_t codeLNAMES; /* Index of the LNAMES for "CODE" class */
|
||||
uint8_t codeSEGDEF; /* Index of the first SEGDEF that has class CODE */
|
||||
#define NONE 0xFF /* Improbable segment index */
|
||||
uint8_t lnum = 0; /* Count of LNAMES so far */
|
||||
uint8_t segnum = 0; /* Count of SEGDEFs so far */
|
||||
uint8_t codeLNAMES; /* Index of the LNAMES for "CODE" class */
|
||||
uint8_t codeSEGDEF; /* Index of the first SEGDEF that has class CODE */
|
||||
#define NONE 0xFF /* Improbable segment index */
|
||||
uint8_t *leData; /* Pointer to 64K of alloc'd data. Some .lib files
|
||||
have the symbols (PUBDEFs) *after* the data
|
||||
(LEDATA), so you need to keep the data here */
|
||||
uint16_t maxLeData; /* How much data we have in there */
|
||||
uint16_t maxLeData; /* How much data we have in there */
|
||||
/* read a length then string to buf[]; make it an asciiz string */
|
||||
void readString( FILE *fl);
|
||||
|
||||
|
||||
@@ -21,17 +21,17 @@ void TPL_PatternCollector::enterSym(FILE *f, const char *name, uint16_t pmapOffs
|
||||
/* Enter a symbol with given name */
|
||||
allocSym(count);
|
||||
strcpy(keys[count].name, name);
|
||||
pm = pmap + pmapOffset; /* Pointer to the 4 byte pmap structure */
|
||||
pm = pmap + pmapOffset; /* Pointer to the 4 byte pmap structure */
|
||||
fseek(f, unitBase+pm, SEEK_SET);/* Go there */
|
||||
cm = readShort(f); /* CSeg map offset */
|
||||
codeOffset = readShort(f); /* How far into the code segment is our rtn */
|
||||
j = cm / 8; /* Index into the cmap array */
|
||||
cm = readShort(f); /* CSeg map offset */
|
||||
codeOffset = readShort(f); /* How far into the code segment is our rtn */
|
||||
j = cm / 8; /* Index into the cmap array */
|
||||
pcode = csegBase+csegoffs[j]+codeOffset;
|
||||
fseek(f, unitBase+pcode, SEEK_SET); /* Go there */
|
||||
grab(f,PATLEN); /* Grab the pattern to buf[] */
|
||||
fixWildCards(buf); /* Fix the wild cards */
|
||||
fseek(f, unitBase+pcode, SEEK_SET); /* Go there */
|
||||
grab(f,PATLEN); /* Grab the pattern to buf[] */
|
||||
fixWildCards(buf); /* Fix the wild cards */
|
||||
memcpy(keys[count].pat, buf, PATLEN); /* Copy to the key array */
|
||||
count++; /* Done one more */
|
||||
count++; /* Done one more */
|
||||
}
|
||||
|
||||
void TPL_PatternCollector::allocSym(int count)
|
||||
@@ -50,7 +50,7 @@ void TPL_PatternCollector::readCmapOffsets(FILE *f)
|
||||
csegIdx = 0;
|
||||
for (i=cmap; i < pmap; i+=8)
|
||||
{
|
||||
readShort(f); /* Always 0 */
|
||||
readShort(f); /* Always 0 */
|
||||
csize = readShort(f);
|
||||
if (csize == 0xFFFF) continue; /* Ignore the first one... unit init */
|
||||
csegoffs[csegIdx++] = cumsize;
|
||||
@@ -70,7 +70,7 @@ void TPL_PatternCollector::enterSystemUnit(FILE *f)
|
||||
cmap = readShort(f);
|
||||
pmap = readShort(f);
|
||||
fseek(f, offStCseg, SEEK_SET);
|
||||
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
|
||||
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
|
||||
printf("CMAP table at %04X\n", cmap);
|
||||
printf("PMAP table at %04X\n", pmap);
|
||||
printf("Code seg base %04X\n", csegBase);
|
||||
@@ -79,10 +79,10 @@ void TPL_PatternCollector::enterSystemUnit(FILE *f)
|
||||
|
||||
enterSym(f,"INITIALISE", 0x04);
|
||||
enterSym(f,"UNKNOWN008", 0x08);
|
||||
enterSym(f,"EXIT", 0x0C);
|
||||
enterSym(f,"EXIT", 0x0C);
|
||||
enterSym(f,"BlockMove", 0x10);
|
||||
unknown(f,0x14, 0xC8);
|
||||
enterSym(f,"PostIO", 0xC8);
|
||||
enterSym(f,"PostIO", 0xC8);
|
||||
enterSym(f,"UNKNOWN0CC", 0xCC);
|
||||
enterSym(f,"STACKCHK", 0xD0);
|
||||
enterSym(f,"UNKNOWN0D4", 0xD4);
|
||||
@@ -90,24 +90,24 @@ void TPL_PatternCollector::enterSystemUnit(FILE *f)
|
||||
enterSym(f,"WriteInt", 0xDC);
|
||||
enterSym(f,"UNKNOWN0E0", 0xE0);
|
||||
enterSym(f,"UNKNOWN0E4", 0xE4);
|
||||
enterSym(f,"CRLF", 0xE8);
|
||||
enterSym(f,"CRLF", 0xE8);
|
||||
enterSym(f,"UNKNOWN0EC", 0xEC);
|
||||
enterSym(f,"UNKNOWN0F0", 0xF0);
|
||||
enterSym(f,"UNKNOWN0F4", 0xF4);
|
||||
enterSym(f,"ReadEOL", 0xF8);
|
||||
enterSym(f,"Read", 0xFC);
|
||||
enterSym(f,"Read", 0xFC);
|
||||
enterSym(f,"UNKNOWN100", 0x100);
|
||||
enterSym(f,"UNKNOWN104", 0x104);
|
||||
enterSym(f,"PostWrite", 0x108);
|
||||
enterSym(f,"UNKNOWN10C", 0x10C);
|
||||
enterSym(f,"Randomize", 0x110);
|
||||
unknown(f,0x114, 0x174);
|
||||
enterSym(f,"Random", 0x174);
|
||||
enterSym(f,"Random", 0x174);
|
||||
unknown(f,0x178, 0x1B8);
|
||||
enterSym(f,"FloatAdd", 0x1B8); /* A guess! */
|
||||
enterSym(f,"FloatSub", 0x1BC); /* disicx - dxbxax -> dxbxax*/
|
||||
enterSym(f,"FloatMult", 0x1C0); /* disicx * dxbxax -> dxbxax*/
|
||||
enterSym(f,"FloatDivide", 0x1C4); /* disicx / dxbxax -> dxbxax*/
|
||||
enterSym(f,"FloatAdd", 0x1B8); /* A guess! */
|
||||
enterSym(f,"FloatSub", 0x1BC); /* disicx - dxbxax -> dxbxax*/
|
||||
enterSym(f,"FloatMult", 0x1C0); /* disicx * dxbxax -> dxbxax*/
|
||||
enterSym(f,"FloatDivide", 0x1C4); /* disicx / dxbxax -> dxbxax*/
|
||||
enterSym(f,"UNKNOWN1C8", 0x1C8);
|
||||
enterSym(f,"DoubleToFloat",0x1CC); /* dxax to dxbxax */
|
||||
enterSym(f,"UNKNOWN1D0", 0x1D0);
|
||||
@@ -163,23 +163,23 @@ void TPL_PatternCollector::nextUnit(FILE *f)
|
||||
void TPL_PatternCollector::setVersionSpecifics()
|
||||
{
|
||||
|
||||
version = buf[3]; /* The x of TPUx */
|
||||
version = buf[3]; /* The x of TPUx */
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case '0': /* Version 4.0 */
|
||||
case '0': /* Version 4.0 */
|
||||
offStCseg = 0x14; /* Offset to the LL giving the Cseg start */
|
||||
charProc = 'T'; /* Indicates a proc in the dictionary */
|
||||
charFunc = 'U'; /* Indicates a function in the dictionary */
|
||||
skipPmap = 6; /* Bytes to skip after Func to get pmap offset */
|
||||
charProc = 'T'; /* Indicates a proc in the dictionary */
|
||||
charFunc = 'U'; /* Indicates a function in the dictionary */
|
||||
skipPmap = 6; /* Bytes to skip after Func to get pmap offset */
|
||||
break;
|
||||
|
||||
|
||||
case '5': /* Version 5.0 */
|
||||
case '5': /* Version 5.0 */
|
||||
offStCseg = 0x18; /* Offset to the LL giving the Cseg start */
|
||||
charProc = 'T'; /* Indicates a proc in the dictionary */
|
||||
charFunc = 'U'; /* Indicates a function in the dictionary */
|
||||
skipPmap = 1; /* Bytes to skip after Func to get pmap offset */
|
||||
charProc = 'T'; /* Indicates a proc in the dictionary */
|
||||
charFunc = 'U'; /* Indicates a function in the dictionary */
|
||||
skipPmap = 1; /* Bytes to skip after Func to get pmap offset */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -225,18 +225,18 @@ void TPL_PatternCollector::enterUnitProcs(FILE *f)
|
||||
cmap = readShort(f);
|
||||
pmap = readShort(f);
|
||||
fseek(f, unitBase+offStCseg, SEEK_SET);
|
||||
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
|
||||
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
|
||||
printf("CMAP table at %04X\n", cmap);
|
||||
printf("PMAP table at %04X\n", pmap);
|
||||
printf("Code seg base %04X\n", csegBase);
|
||||
|
||||
readCmapOffsets(f);
|
||||
|
||||
fseek(f, unitBase+pmap, SEEK_SET); /* Go to first pmap entry */
|
||||
if (readShort(f) != 0xFFFF) /* FFFF means none */
|
||||
fseek(f, unitBase+pmap, SEEK_SET); /* Go to first pmap entry */
|
||||
if (readShort(f) != 0xFFFF) /* FFFF means none */
|
||||
{
|
||||
sprintf(name, "UNIT_INIT_%d", ++unitNum);
|
||||
enterSym(f,name, 0); /* This is the unit init code */
|
||||
enterSym(f,name, 0); /* This is the unit init code */
|
||||
}
|
||||
|
||||
fseek(f, unitBase+0x0A, SEEK_SET);
|
||||
@@ -260,7 +260,7 @@ void TPL_PatternCollector::enterUnitProcs(FILE *f)
|
||||
cat = readByte(f);
|
||||
if ((cat == charProc) or (cat == charFunc))
|
||||
{
|
||||
grab(f,skipPmap); /* Skip to the pmap */
|
||||
grab(f,skipPmap); /* Skip to the pmap */
|
||||
pmapOff = readShort(f); /* pmap offset */
|
||||
printf("pmap offset for %13s: %04X\n", name, pmapOff);
|
||||
enterSym(f,name, pmapOff);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "LIB_PatternCollector.h"
|
||||
#include "TPL_PatternCollector.h"
|
||||
#include "perfhlib.h" /* Symbol table prototypes */
|
||||
#include "perfhlib.h" /* Symbol table prototypes */
|
||||
#include "msvc_fixes.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
/* prototypes */
|
||||
|
||||
void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll); /* Save the info */
|
||||
void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll); /* Save the info */
|
||||
|
||||
int numKeys; /* Number of useful codeview symbols */
|
||||
int numKeys; /* Number of useful codeview symbols */
|
||||
|
||||
|
||||
static void printUsage(bool longusage) {
|
||||
@@ -77,20 +77,20 @@ int main(int argc, char *argv[])
|
||||
srand(s);
|
||||
|
||||
PerfectHash p_hash;
|
||||
numKeys = collector->readSyms(srcfile); /* Read the keys (symbols) */
|
||||
numKeys = collector->readSyms(srcfile); /* Read the keys (symbols) */
|
||||
|
||||
printf("Num keys: %d; vertices: %d\n", numKeys, (int)(numKeys*C));
|
||||
/* Set the parameters for the hash table */
|
||||
p_hash.setHashParams( numKeys, /* The number of symbols */
|
||||
PATLEN, /* The length of the pattern to be hashed */
|
||||
256, /* The character set of the pattern (0-FF) */
|
||||
0, /* Minimum pattern character value */
|
||||
numKeys*C); /* C is the sparseness of the graph. See Czech,
|
||||
p_hash.setHashParams( numKeys, /* The number of symbols */
|
||||
PATLEN, /* The length of the pattern to be hashed */
|
||||
256, /* The character set of the pattern (0-FF) */
|
||||
0, /* Minimum pattern character value */
|
||||
numKeys*C); /* C is the sparseness of the graph. See Czech,
|
||||
Havas and Majewski for details */
|
||||
|
||||
/* The following two functions are in perfhlib.c */
|
||||
p_hash.map(collector); /* Perform the mapping. This will call getKey() repeatedly */
|
||||
p_hash.assign(); /* Generate the function g */
|
||||
p_hash.assign(); /* Generate the function g */
|
||||
|
||||
saveFile(f2,p_hash,collector); /* Save the resultant information */
|
||||
|
||||
@@ -100,9 +100,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * *\
|
||||
* *
|
||||
* S a v e t h e s i g f i l e *
|
||||
* *
|
||||
* *
|
||||
* S a v e t h e s i g f i l e *
|
||||
* *
|
||||
\* * * * * * * * * * * * */
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void writeFileShort(FILE *fl,uint16_t w)
|
||||
uint8_t b;
|
||||
|
||||
b = (uint8_t)(w & 0xFF);
|
||||
writeFile(fl,(char *)&b, 1); /* Write a short little endian */
|
||||
writeFile(fl,(char *)&b, 1); /* Write a short little endian */
|
||||
b = (uint8_t)(w>>8);
|
||||
writeFile(fl,(char *)&b, 1);
|
||||
}
|
||||
@@ -130,14 +130,14 @@ void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll)
|
||||
int i, len;
|
||||
const uint16_t *pTable;
|
||||
|
||||
writeFile(fl,"dccs", 4); /* Signature */
|
||||
writeFileShort(fl,numKeys); /* Number of keys */
|
||||
writeFile(fl,"dccs", 4); /* Signature */
|
||||
writeFileShort(fl,numKeys); /* Number of keys */
|
||||
writeFileShort(fl,(short)(numKeys * C)); /* Number of vertices */
|
||||
writeFileShort(fl,PATLEN); /* Length of key part of entries */
|
||||
writeFileShort(fl,SYMLEN); /* Length of symbol part of entries */
|
||||
writeFileShort(fl,PATLEN); /* Length of key part of entries */
|
||||
writeFileShort(fl,SYMLEN); /* Length of symbol part of entries */
|
||||
|
||||
/* Write out the tables T1 and T2, with their sig and byte lengths in front */
|
||||
writeFile(fl,"T1", 2); /* "Signature" */
|
||||
writeFile(fl,"T1", 2); /* "Signature" */
|
||||
pTable = p_hash.readT1();
|
||||
len = PATLEN * 256;
|
||||
writeFileShort(fl,len * sizeof(uint16_t));
|
||||
@@ -154,7 +154,7 @@ void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll)
|
||||
}
|
||||
|
||||
/* Write out g[] */
|
||||
writeFile(fl,"gg", 2); /* "Signature" */
|
||||
writeFile(fl,"gg", 2); /* "Signature" */
|
||||
pTable = p_hash.readG();
|
||||
len = (short)(numKeys * C);
|
||||
writeFileShort(fl,len * sizeof(uint16_t));
|
||||
@@ -164,7 +164,7 @@ void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll)
|
||||
}
|
||||
|
||||
/* Now the hash table itself */
|
||||
writeFile(fl,"ht ", 2); /* "Signature" */
|
||||
writeFile(fl,"ht ", 2); /* "Signature" */
|
||||
writeFileShort(fl,numKeys * (SYMLEN + PATLEN + sizeof(uint16_t))); /* byte len */
|
||||
for (i=0; i < numKeys; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user