mirror of
https://github.com/reactos/reactos.git
synced 2024-07-30 16:18:43 +00:00
RSYM: force all sym files to have 0-based function offsets.
NTOSKRNL: look for 0-based offsets instead of absolute offsets. svn path=/trunk/; revision=12127
This commit is contained in:
parent
262a6b4866
commit
66468c3013
|
@ -88,12 +88,10 @@ KdbpStabFindEntry(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
||||||
|
|
||||||
if (RelativeAddress != NULL)
|
if (RelativeAddress != NULL)
|
||||||
{
|
{
|
||||||
if (StabEntry->n_value < (ULONG_PTR)SymbolInfo->ImageBase)
|
if (StabEntry->n_value >= SymbolInfo->ImageSize)
|
||||||
continue;
|
|
||||||
if (StabEntry->n_value >= ((ULONG_PTR)SymbolInfo->ImageBase + SymbolInfo->ImageSize))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SymbolRelativeAddress = StabEntry->n_value - (ULONG_PTR)SymbolInfo->ImageBase;
|
SymbolRelativeAddress = StabEntry->n_value;
|
||||||
if ((SymbolRelativeAddress <= (ULONG_PTR)RelativeAddress) &&
|
if ((SymbolRelativeAddress <= (ULONG_PTR)RelativeAddress) &&
|
||||||
(SymbolRelativeAddress > AddrFound))
|
(SymbolRelativeAddress > AddrFound))
|
||||||
{
|
{
|
||||||
|
@ -109,9 +107,13 @@ KdbpStabFindEntry(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BestStabEntry == NULL)
|
if (BestStabEntry == NULL)
|
||||||
|
{
|
||||||
DPRINT("StabEntry not found!\n");
|
DPRINT("StabEntry not found!\n");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
DPRINT("StabEntry found!\n");
|
DPRINT("StabEntry found!\n");
|
||||||
|
}
|
||||||
|
|
||||||
return BestStabEntry;
|
return BestStabEntry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ typedef struct _STAB_ENTRY {
|
||||||
#define N_SLINE 0x44
|
#define N_SLINE 0x44
|
||||||
#define N_SO 0x64
|
#define N_SO 0x64
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned long OldOffset;
|
unsigned long OldOffset;
|
||||||
unsigned long NewOffset;
|
unsigned long NewOffset;
|
||||||
|
@ -137,9 +137,9 @@ char* convert_path(char* origpath)
|
||||||
{
|
{
|
||||||
char* newpath;
|
char* newpath;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
newpath = strdup(origpath);
|
newpath = strdup(origpath);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (newpath[i] != 0)
|
while (newpath[i] != 0)
|
||||||
{
|
{
|
||||||
|
@ -154,8 +154,8 @@ char* convert_path(char* origpath)
|
||||||
{
|
{
|
||||||
newpath[i] = '\\';
|
newpath[i] = '\\';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return(newpath);
|
return(newpath);
|
||||||
|
@ -168,7 +168,9 @@ int main(int argc, char* argv[])
|
||||||
SYMBOLFILE_HEADER SymbolFileHeader;
|
SYMBOLFILE_HEADER SymbolFileHeader;
|
||||||
IMAGE_DOS_HEADER PEDosHeader;
|
IMAGE_DOS_HEADER PEDosHeader;
|
||||||
IMAGE_FILE_HEADER PEFileHeader;
|
IMAGE_FILE_HEADER PEFileHeader;
|
||||||
|
PIMAGE_OPTIONAL_HEADER PEOptHeader;
|
||||||
PIMAGE_SECTION_HEADER PESectionHeaders;
|
PIMAGE_SECTION_HEADER PESectionHeaders;
|
||||||
|
ULONG ImageBase;
|
||||||
PVOID SymbolsBase;
|
PVOID SymbolsBase;
|
||||||
ULONG SymbolsLength;
|
ULONG SymbolsLength;
|
||||||
PVOID SymbolStringsBase;
|
PVOID SymbolStringsBase;
|
||||||
|
@ -187,16 +189,16 @@ int main(int argc, char* argv[])
|
||||||
PSTR_ENTRY StrEntry;
|
PSTR_ENTRY StrEntry;
|
||||||
ULONG StrCount;
|
ULONG StrCount;
|
||||||
ULONG j;
|
ULONG j;
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Too many arguments\n");
|
fprintf(stderr, "Too many arguments\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
path1 = convert_path(argv[1]);
|
path1 = convert_path(argv[1]);
|
||||||
path2 = convert_path(argv[2]);
|
path2 = convert_path(argv[2]);
|
||||||
|
|
||||||
in = fopen(path1, "rb");
|
in = fopen(path1, "rb");
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
{
|
{
|
||||||
|
@ -224,6 +226,11 @@ int main(int argc, char* argv[])
|
||||||
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG), SEEK_SET);
|
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG), SEEK_SET);
|
||||||
n_in = fread(&PEFileHeader, 1, sizeof(PEFileHeader), in);
|
n_in = fread(&PEFileHeader, 1, sizeof(PEFileHeader), in);
|
||||||
|
|
||||||
|
/* Read optional header */
|
||||||
|
PEOptHeader = malloc(PEFileHeader.SizeOfOptionalHeader);
|
||||||
|
fread ( PEOptHeader, 1, PEFileHeader.SizeOfOptionalHeader, in );
|
||||||
|
ImageBase = PEOptHeader->ImageBase;
|
||||||
|
|
||||||
/* Read PE section headers */
|
/* Read PE section headers */
|
||||||
PESectionHeaders = malloc(PEFileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER));
|
PESectionHeaders = malloc(PEFileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER));
|
||||||
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG) + sizeof(IMAGE_FILE_HEADER)
|
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG) + sizeof(IMAGE_FILE_HEADER)
|
||||||
|
@ -242,7 +249,7 @@ int main(int argc, char* argv[])
|
||||||
if ((strncmp(PESectionHeaders[Idx].Name, ".stab", 5) == 0)
|
if ((strncmp(PESectionHeaders[Idx].Name, ".stab", 5) == 0)
|
||||||
&& (PESectionHeaders[Idx].Name[5] == 0))
|
&& (PESectionHeaders[Idx].Name[5] == 0))
|
||||||
{
|
{
|
||||||
//printf(".stab section found. Size %d\n",
|
//printf(".stab section found. Size %d\n",
|
||||||
// PESectionHeaders[Idx].SizeOfRawData);
|
// PESectionHeaders[Idx].SizeOfRawData);
|
||||||
|
|
||||||
SymbolsLength = PESectionHeaders[Idx].SizeOfRawData;
|
SymbolsLength = PESectionHeaders[Idx].SizeOfRawData;
|
||||||
|
@ -254,7 +261,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
if (strncmp(PESectionHeaders[Idx].Name, ".stabstr", 8) == 0)
|
if (strncmp(PESectionHeaders[Idx].Name, ".stabstr", 8) == 0)
|
||||||
{
|
{
|
||||||
//printf(".stabstr section found. Size %d\n",
|
//printf(".stabstr section found. Size %d\n",
|
||||||
// PESectionHeaders[Idx].SizeOfRawData);
|
// PESectionHeaders[Idx].SizeOfRawData);
|
||||||
|
|
||||||
SymbolStringsLength = PESectionHeaders[Idx].SizeOfRawData;
|
SymbolStringsLength = PESectionHeaders[Idx].SizeOfRawData;
|
||||||
|
@ -276,6 +283,8 @@ int main(int argc, char* argv[])
|
||||||
StabEntry[i].n_type == N_SO)
|
StabEntry[i].n_type == N_SO)
|
||||||
{
|
{
|
||||||
memmove(&StabEntry[Count], &StabEntry[i], sizeof(STAB_ENTRY));
|
memmove(&StabEntry[Count], &StabEntry[i], sizeof(STAB_ENTRY));
|
||||||
|
if ( StabEntry[Count].n_value >= ImageBase )
|
||||||
|
StabEntry[Count].n_value -= ImageBase;
|
||||||
Count++;
|
Count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue