* exeinfo: Return executable image base and current module base address on Windows.

* exeinfo: Properly handle long COFF section names. Bug #13499.
* lineinfo, lnfodwrf: Properly use executable image base and current module base address.

git-svn-id: trunk@13145 -
This commit is contained in:
yury 2009-05-15 22:14:09 +00:00
parent 66c0840bce
commit 628b0c23ac
3 changed files with 14 additions and 12 deletions

View File

@ -83,6 +83,7 @@ uses
filename:=ParamStr(0) filename:=ParamStr(0)
else else
begin begin
baseaddr:=Tmm.AllocationBase;
TST[0]:= #0; TST[0]:= #0;
GetModuleFileName(THandle(Tmm.AllocationBase), TST, Length(TST)); GetModuleFileName(THandle(Tmm.AllocationBase), TST, Length(TST));
{$ifdef wince} {$ifdef wince}
@ -494,9 +495,10 @@ begin
exit; exit;
e.sechdrofs:=filepos(e.f); e.sechdrofs:=filepos(e.f);
e.nsects:=peheader.NumberOfSections; e.nsects:=peheader.NumberOfSections;
e.secstrofs:=peheader.PointerToSymbolTable+peheader.NumberOfSymbols*sizeof(coffsymbol)+4; e.secstrofs:=peheader.PointerToSymbolTable+peheader.NumberOfSymbols*sizeof(coffsymbol);
if e.secstrofs>e.size then if e.secstrofs>e.size then
exit; exit;
e.processaddress:=peheader.ImageBase;
OpenPeCoff:=true; OpenPeCoff:=true;
end; end;
{$endif PE32} {$endif PE32}
@ -522,8 +524,7 @@ type
SizeOfUninitializedData : longint; SizeOfUninitializedData : longint;
AddressOfEntryPoint : longint; AddressOfEntryPoint : longint;
BaseOfCode : longint; BaseOfCode : longint;
BaseOfData : longint; ImageBase : qword;
ImageBase : longint;
SectionAlignment : longint; SectionAlignment : longint;
FileAlignment : longint; FileAlignment : longint;
MajorOperatingSystemVersion : word; MajorOperatingSystemVersion : word;
@ -538,10 +539,10 @@ type
CheckSum : longint; CheckSum : longint;
Subsystem : word; Subsystem : word;
DllCharacteristics : word; DllCharacteristics : word;
SizeOfStackReserve : int64; SizeOfStackReserve : qword;
SizeOfStackCommit : int64; SizeOfStackCommit : qword;
SizeOfHeapReserve : int64; SizeOfHeapReserve : qword;
SizeOfHeapCommit : int64; SizeOfHeapCommit : qword;
LoaderFlags : longint; LoaderFlags : longint;
NumberOfRvaAndSizes : longint; NumberOfRvaAndSizes : longint;
DataDirectory : array[1..$80] of byte; DataDirectory : array[1..$80] of byte;
@ -561,9 +562,10 @@ begin
exit; exit;
e.sechdrofs:=filepos(e.f); e.sechdrofs:=filepos(e.f);
e.nsects:=peheader.NumberOfSections; e.nsects:=peheader.NumberOfSections;
e.secstrofs:=peheader.PointerToSymbolTable+peheader.NumberOfSymbols*sizeof(coffsymbol)+4; e.secstrofs:=peheader.PointerToSymbolTable+peheader.NumberOfSymbols*sizeof(coffsymbol);
if e.secstrofs>e.size then if e.secstrofs>e.size then
exit; exit;
e.processaddress:=peheader.ImageBase;
OpenPePlusCoff:=true; OpenPePlusCoff:=true;
end; end;
{$endif PE32PLUS} {$endif PE32PLUS}

View File

@ -95,7 +95,7 @@ begin
if not OpenExeFile(e,dbgfn) then if not OpenExeFile(e,dbgfn) then
exit; exit;
end; end;
e.processaddress:=e.processaddress+dword(baseaddr); e.processaddress:=ptruint(baseaddr)-e.processaddress;
StabsFunctionRelative := E.FunctionRelative; StabsFunctionRelative := E.FunctionRelative;
if FindExeSection(e,'.stab',stabofs,stablen) and if FindExeSection(e,'.stab',stabofs,stablen) and
FindExeSection(e,'.stabstr',stabstrofs,stabstrlen) then FindExeSection(e,'.stabstr',stabstrofs,stabstrlen) then
@ -142,7 +142,7 @@ begin
{ correct the value to the correct address in the file } { correct the value to the correct address in the file }
{ processaddress is set in OpenStabs } { processaddress is set in OpenStabs }
addr := addr - e.processaddress; addr := dword(addr - e.processaddress);
{$ifdef DEBUG_LINEINFO} {$ifdef DEBUG_LINEINFO}
writeln(stderr,'Addr: ',hexstr(addr,sizeof(addr)*2)); writeln(stderr,'Addr: ',hexstr(addr,sizeof(addr)*2));

View File

@ -153,7 +153,7 @@ begin
exit; exit;
end; end;
e.processaddress:=e.processaddress+dword(baseaddr); e.processaddress:=ptruint(baseaddr)-e.processaddress;
if FindExeSection(e,'.debug_line',dwarfoffset,dwarfsize) then if FindExeSection(e,'.debug_line',dwarfoffset,dwarfsize) then
Opendwarf:=true Opendwarf:=true