* 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

@ -78,11 +78,12 @@ uses
{$endif wince}
procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: string);
begin
baseaddr:= nil;
baseaddr:=nil;
if VirtualQuery(addr, @Tmm, SizeOf(Tmm))<>sizeof(Tmm) then
filename:=ParamStr(0)
else
begin
baseaddr:=Tmm.AllocationBase;
TST[0]:= #0;
GetModuleFileName(THandle(Tmm.AllocationBase), TST, Length(TST));
{$ifdef wince}
@ -494,9 +495,10 @@ begin
exit;
e.sechdrofs:=filepos(e.f);
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
exit;
e.processaddress:=peheader.ImageBase;
OpenPeCoff:=true;
end;
{$endif PE32}
@ -522,8 +524,7 @@ type
SizeOfUninitializedData : longint;
AddressOfEntryPoint : longint;
BaseOfCode : longint;
BaseOfData : longint;
ImageBase : longint;
ImageBase : qword;
SectionAlignment : longint;
FileAlignment : longint;
MajorOperatingSystemVersion : word;
@ -538,10 +539,10 @@ type
CheckSum : longint;
Subsystem : word;
DllCharacteristics : word;
SizeOfStackReserve : int64;
SizeOfStackCommit : int64;
SizeOfHeapReserve : int64;
SizeOfHeapCommit : int64;
SizeOfStackReserve : qword;
SizeOfStackCommit : qword;
SizeOfHeapReserve : qword;
SizeOfHeapCommit : qword;
LoaderFlags : longint;
NumberOfRvaAndSizes : longint;
DataDirectory : array[1..$80] of byte;
@ -561,9 +562,10 @@ begin
exit;
e.sechdrofs:=filepos(e.f);
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
exit;
e.processaddress:=peheader.ImageBase;
OpenPePlusCoff:=true;
end;
{$endif PE32PLUS}

View File

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

View File

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