Author: akhaldi
Date: Sun Sep 1 11:17:36 2013
New Revision: 59936
URL:
http://svn.reactos.org/svn/reactos?rev=59936&view=rev
Log:
[RSYM]
* Fix long section names and correct some wrong use of ULONG_PTR. Brought to you by Arty.
Modified:
trunk/reactos/tools/rsym/rsym.c
Modified: trunk/reactos/tools/rsym/rsym.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rsym/rsym.c?rev=5993…
==============================================================================
--- trunk/reactos/tools/rsym/rsym.c [iso-8859-1] (original)
+++ trunk/reactos/tools/rsym/rsym.c [iso-8859-1] Sun Sep 1 11:17:36 2013
@@ -914,12 +914,18 @@
/* Each coff symbol is 18 bytes and the string table follows */
char *StringTable = (char *)InData +
InFileHeader->PointerToSymbolTable + 18 * InFileHeader->NumberOfSymbols;
+ ULONG StringTableLength = 0;
+ ULONG StringTableLocation;
StartOfRawData = 0;
for (Section = 0; Section < InFileHeader->NumberOfSections; Section++)
{
const BYTE *SectionName = GetSectionName(StringTable,
InSectionHeaders[Section].Name);
+ if (InSectionHeaders[Section].Name[0] == '/')
+ {
+ StringTableLength = atoi(InSectionHeaders[Section].Name+1) +
strlen(SectionName) + 1;
+ }
if ((StartOfRawData == 0 || InSectionHeaders[Section].PointerToRawData <
StartOfRawData)
&& InSectionHeaders[Section].PointerToRawData != 0
&& (strncmp((char *) SectionName, ".stab", 5)) != 0
@@ -979,6 +985,9 @@
OutOptHeader->SizeOfImage = 0;
RosSymOffset = 0;
OutRelocSection = NULL;
+
+ StringTableLocation = StartOfRawData;
+
for (Section = 0; Section < InFileHeader->NumberOfSections; Section++)
{
const BYTE *SectionName = GetSectionName(StringTable,
@@ -1004,6 +1013,7 @@
{
OutRelocSection = CurrentSectionHeader;
}
+ StringTableLocation = CurrentSectionHeader->PointerToRawData +
CurrentSectionHeader->SizeOfRawData;
(OutFileHeader->NumberOfSections)++;
CurrentSectionHeader++;
}
@@ -1062,11 +1072,22 @@
memset((char *) PaddedRosSym + RosSymLength,
'\0',
RosSymFileLength - RosSymLength);
+
+ /* Position the string table after our new section */
+ StringTableLocation = RosSymOffset + RosSymFileLength;
}
else
{
PaddedRosSym = NULL;
}
+
+ /* Set the string table area in the header if we need it */
+ if (StringTableLength)
+ {
+ OutFileHeader->PointerToSymbolTable = StringTableLocation;
+ OutFileHeader->NumberOfSymbols = 0;
+ }
+
CheckSum = 0;
for (i = 0; i < StartOfRawData / 2; i++)
{
@@ -1139,6 +1160,14 @@
}
}
}
+
+ fseek(OutFile, OutFileHeader->PointerToSymbolTable, 0);
+ /* COFF string section is preceeded by a length */
+ 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, OutFile);
if (PaddedRosSym)
{