mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 12:40:33 +00:00
[RSYM]
- Include string table in checksum calculation CORE-7547 #resolve svn path=/trunk/; revision=60852
This commit is contained in:
parent
d5e5e58ebf
commit
16c4fe33fb
1 changed files with 45 additions and 29 deletions
|
@ -212,7 +212,7 @@ FindOrAddString(struct StringHashTable *StringTable,
|
||||||
*StringsLength += strlen(StringToFind) + 1;
|
*StringsLength += strlen(StringToFind) + 1;
|
||||||
|
|
||||||
AddStringToHash(StringTable, hash, End - (char *)StringsBase, End);
|
AddStringToHash(StringTable, hash, End - (char *)StringsBase, End);
|
||||||
|
|
||||||
return End - (char *)StringsBase;
|
return End - (char *)StringsBase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ DbgHelpAddStringToTable(struct DbgHelpStringTab *tab, char *name)
|
||||||
int i;
|
int i;
|
||||||
char **newBucket;
|
char **newBucket;
|
||||||
|
|
||||||
if (tabEnt)
|
if (tabEnt)
|
||||||
{
|
{
|
||||||
for (i = 0; tabEnt[i] && strcmp(tabEnt[i], name); i++);
|
for (i = 0; tabEnt[i] && strcmp(tabEnt[i], name); i++);
|
||||||
if (tabEnt[i])
|
if (tabEnt[i])
|
||||||
|
@ -773,7 +773,7 @@ MergeStabsAndCoffs(ULONG *MergedSymbolCount, PROSSYM_ENTRY *MergedSymbols,
|
||||||
(*MergedSymbolCount)++;
|
(*MergedSymbolCount)++;
|
||||||
}
|
}
|
||||||
/* Handle functions that have no analog in the upstream data */
|
/* Handle functions that have no analog in the upstream data */
|
||||||
for (CoffIndex = 0; CoffIndex < CoffSymbolsCount; CoffIndex++)
|
for (CoffIndex = 0; CoffIndex < CoffSymbolsCount; CoffIndex++)
|
||||||
{
|
{
|
||||||
if (CoffSymbols[CoffIndex].Address &&
|
if (CoffSymbols[CoffIndex].Address &&
|
||||||
CoffSymbols[CoffIndex].FunctionOffset)
|
CoffSymbols[CoffIndex].FunctionOffset)
|
||||||
|
@ -901,6 +901,7 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
ULONG StartOfRawData;
|
ULONG StartOfRawData;
|
||||||
unsigned Section;
|
unsigned Section;
|
||||||
void *OutHeader, *ProcessedRelocs, *PaddedRosSym, *Data;
|
void *OutHeader, *ProcessedRelocs, *PaddedRosSym, *Data;
|
||||||
|
unsigned char *PaddedStringTable;
|
||||||
PIMAGE_DOS_HEADER OutDosHeader;
|
PIMAGE_DOS_HEADER OutDosHeader;
|
||||||
PIMAGE_FILE_HEADER OutFileHeader;
|
PIMAGE_FILE_HEADER OutFileHeader;
|
||||||
PIMAGE_OPTIONAL_HEADER OutOptHeader;
|
PIMAGE_OPTIONAL_HEADER OutOptHeader;
|
||||||
|
@ -909,10 +910,11 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
ULONG Length, i;
|
ULONG Length, i;
|
||||||
ULONG ProcessedRelocsLength;
|
ULONG ProcessedRelocsLength;
|
||||||
ULONG RosSymOffset, RosSymFileLength;
|
ULONG RosSymOffset, RosSymFileLength;
|
||||||
|
ULONG PaddedStringTableLength;
|
||||||
int InRelocSectionIndex;
|
int InRelocSectionIndex;
|
||||||
PIMAGE_SECTION_HEADER OutRelocSection;
|
PIMAGE_SECTION_HEADER OutRelocSection;
|
||||||
/* Each coff symbol is 18 bytes and the string table follows */
|
/* Each coff symbol is 18 bytes and the string table follows */
|
||||||
char *StringTable = (char *)InData +
|
char *StringTable = (char *)InData +
|
||||||
InFileHeader->PointerToSymbolTable + 18 * InFileHeader->NumberOfSymbols;
|
InFileHeader->PointerToSymbolTable + 18 * InFileHeader->NumberOfSymbols;
|
||||||
ULONG StringTableLength = 0;
|
ULONG StringTableLength = 0;
|
||||||
ULONG StringTableLocation;
|
ULONG StringTableLocation;
|
||||||
|
@ -1014,7 +1016,7 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
OutRelocSection = CurrentSectionHeader;
|
OutRelocSection = CurrentSectionHeader;
|
||||||
}
|
}
|
||||||
StringTableLocation = CurrentSectionHeader->PointerToRawData + CurrentSectionHeader->SizeOfRawData;
|
StringTableLocation = CurrentSectionHeader->PointerToRawData + CurrentSectionHeader->SizeOfRawData;
|
||||||
(OutFileHeader->NumberOfSections)++;
|
OutFileHeader->NumberOfSections++;
|
||||||
CurrentSectionHeader++;
|
CurrentSectionHeader++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1060,7 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
| IMAGE_SCN_LNK_REMOVE | IMAGE_SCN_TYPE_NOLOAD;
|
| IMAGE_SCN_LNK_REMOVE | IMAGE_SCN_TYPE_NOLOAD;
|
||||||
OutOptHeader->SizeOfImage = ROUND_UP(CurrentSectionHeader->VirtualAddress + CurrentSectionHeader->Misc.VirtualSize,
|
OutOptHeader->SizeOfImage = ROUND_UP(CurrentSectionHeader->VirtualAddress + CurrentSectionHeader->Misc.VirtualSize,
|
||||||
OutOptHeader->SectionAlignment);
|
OutOptHeader->SectionAlignment);
|
||||||
(OutFileHeader->NumberOfSections)++;
|
OutFileHeader->NumberOfSections++;
|
||||||
|
|
||||||
PaddedRosSym = malloc(RosSymFileLength);
|
PaddedRosSym = malloc(RosSymFileLength);
|
||||||
if (PaddedRosSym == NULL)
|
if (PaddedRosSym == NULL)
|
||||||
|
@ -1120,6 +1122,37 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
}
|
}
|
||||||
Length += OutSectionHeaders[Section].SizeOfRawData;
|
Length += OutSectionHeaders[Section].SizeOfRawData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OutFileHeader->PointerToSymbolTable)
|
||||||
|
{
|
||||||
|
int PaddingFrom = (OutFileHeader->PointerToSymbolTable + StringTableLength) %
|
||||||
|
OutOptHeader->FileAlignment;
|
||||||
|
int PaddingSize = PaddingFrom ? OutOptHeader->FileAlignment - PaddingFrom : 0;
|
||||||
|
|
||||||
|
PaddedStringTableLength = StringTableLength + PaddingSize;
|
||||||
|
PaddedStringTable = malloc(PaddedStringTableLength);
|
||||||
|
/* COFF string section is preceeded by a length */
|
||||||
|
assert(sizeof(StringTableLength) == 4);
|
||||||
|
memcpy(PaddedStringTable, &StringTableLength, sizeof(StringTableLength));
|
||||||
|
/* We just copy enough of the string table to contain the strings we want
|
||||||
|
The string table length technically counts as part of the string table
|
||||||
|
space itself. */
|
||||||
|
memcpy(PaddedStringTable + 4, StringTable + 4, StringTableLength - 4);
|
||||||
|
memset(PaddedStringTable + StringTableLength, 0, PaddingSize);
|
||||||
|
|
||||||
|
assert(OutFileHeader->PointerToSymbolTable % 2 == 0);
|
||||||
|
for (i = 0; i < PaddedStringTableLength / 2; i++)
|
||||||
|
{
|
||||||
|
CheckSum += ((unsigned short*)PaddedStringTable)[i];
|
||||||
|
CheckSum = 0xffff & (CheckSum + (CheckSum >> 16));
|
||||||
|
}
|
||||||
|
Length += PaddedStringTableLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PaddedStringTable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
CheckSum += Length;
|
CheckSum += Length;
|
||||||
OutOptHeader->CheckSum = CheckSum;
|
OutOptHeader->CheckSum = CheckSum;
|
||||||
|
|
||||||
|
@ -1161,28 +1194,11 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutFileHeader->PointerToSymbolTable)
|
if (PaddedStringTable)
|
||||||
{
|
{
|
||||||
int PaddingFrom = (OutFileHeader->PointerToSymbolTable + StringTableLength) %
|
fseek(OutFile, OutFileHeader->PointerToSymbolTable, SEEK_SET);
|
||||||
OutOptHeader->FileAlignment;
|
fwrite(PaddedStringTable, 1, PaddedStringTableLength, OutFile);
|
||||||
fseek(OutFile, OutFileHeader->PointerToSymbolTable, 0);
|
free(PaddedStringTable);
|
||||||
|
|
||||||
/* COFF string section is preceeded by a length */
|
|
||||||
assert(sizeof(StringTableLength) == 4);
|
|
||||||
fwrite((char*)&StringTableLength, 1, sizeof(StringTableLength), OutFile);
|
|
||||||
/* We just copy enough of the string table to contain the strings we want
|
|
||||||
The string table length technically counts as part of the string table
|
|
||||||
space itself. */
|
|
||||||
fwrite(StringTable + 4, 1, StringTableLength - 4, OutFile);
|
|
||||||
|
|
||||||
if (PaddingFrom)
|
|
||||||
{
|
|
||||||
int PaddingSize = OutOptHeader->FileAlignment - PaddingFrom;
|
|
||||||
char *Padding = (char *)malloc(PaddingSize);
|
|
||||||
memset(Padding, 0, PaddingFrom);
|
|
||||||
fwrite(Padding, 1, PaddingSize, OutFile);
|
|
||||||
free(Padding);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PaddedRosSym)
|
if (PaddedRosSym)
|
||||||
|
@ -1325,10 +1341,10 @@ int main(int argc, char* argv[])
|
||||||
// SYMOPT_LOAD_LINES
|
// SYMOPT_LOAD_LINES
|
||||||
SymSetOptions(0x10000 | 0x800000 | 0x40 | 0x10);
|
SymSetOptions(0x10000 | 0x800000 | 0x40 | 0x10);
|
||||||
SymInitialize(FileData, ".", 0);
|
SymInitialize(FileData, ".", 0);
|
||||||
|
|
||||||
module_base = SymLoadModule(FileData, file, path1, path1, 0, FileSize) & 0xffffffff;
|
module_base = SymLoadModule(FileData, file, path1, path1, 0, FileSize) & 0xffffffff;
|
||||||
|
|
||||||
if (ConvertDbgHelp(FileData,
|
if (ConvertDbgHelp(FileData,
|
||||||
module_base,
|
module_base,
|
||||||
SourcePath,
|
SourcePath,
|
||||||
&StabSymbolsCount,
|
&StabSymbolsCount,
|
||||||
|
|
Loading…
Reference in a new issue