mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:46:00 +02:00
* Implemented link map generation without involving TObjSection.ObjSymbolDefines, and removed the latter because it isn't used otherwise. The new approach uses CPU/memory only when map generation is requested.
git-svn-id: trunk@21737 -
This commit is contained in:
parent
b0462d27cc
commit
c65abdeeae
@ -201,8 +201,6 @@ interface
|
|||||||
DataAlignBytes : shortint;
|
DataAlignBytes : shortint;
|
||||||
{ Relocations (=references) to other sections }
|
{ Relocations (=references) to other sections }
|
||||||
ObjRelocations : TFPObjectList;
|
ObjRelocations : TFPObjectList;
|
||||||
{ Symbols this defines }
|
|
||||||
ObjSymbolDefines : TFPObjectList;
|
|
||||||
{ executable linking }
|
{ executable linking }
|
||||||
ExeSection : TExeSection;
|
ExeSection : TExeSection;
|
||||||
USed : Boolean;
|
USed : Boolean;
|
||||||
@ -217,7 +215,6 @@ interface
|
|||||||
procedure alloc(l:aword);
|
procedure alloc(l:aword);
|
||||||
procedure addsymReloc(ofs:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
|
procedure addsymReloc(ofs:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
|
||||||
procedure addsectionReloc(ofs:aword;aobjsec:TObjSection;Reloctype:TObjRelocationType);
|
procedure addsectionReloc(ofs:aword;aobjsec:TObjSection;Reloctype:TObjRelocationType);
|
||||||
procedure AddSymbolDefine(p:TObjSymbol);
|
|
||||||
procedure FixupRelocs(Exe: TExeOutput);virtual;
|
procedure FixupRelocs(Exe: TExeOutput);virtual;
|
||||||
procedure ReleaseData;
|
procedure ReleaseData;
|
||||||
function FullName:string;
|
function FullName:string;
|
||||||
@ -648,7 +645,6 @@ implementation
|
|||||||
secsymidx:=0;
|
secsymidx:=0;
|
||||||
{ relocation }
|
{ relocation }
|
||||||
ObjRelocations:=TFPObjectList.Create(true);
|
ObjRelocations:=TFPObjectList.Create(true);
|
||||||
ObjSymbolDefines:=TFPObjectList.Create(false);
|
|
||||||
VTRefList:=TFPObjectList.Create(false);
|
VTRefList:=TFPObjectList.Create(false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -659,7 +655,6 @@ implementation
|
|||||||
Data.Free;
|
Data.Free;
|
||||||
stringdispose(FCachedFullName);
|
stringdispose(FCachedFullName);
|
||||||
ObjRelocations.Free;
|
ObjRelocations.Free;
|
||||||
ObjSymbolDefines.Free;
|
|
||||||
VTRefList.Free;
|
VTRefList.Free;
|
||||||
inherited destroy;
|
inherited destroy;
|
||||||
end;
|
end;
|
||||||
@ -752,14 +747,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TObjSection.AddSymbolDefine(p:TObjSymbol);
|
|
||||||
begin
|
|
||||||
if p.bind<>AB_GLOBAL then
|
|
||||||
exit;
|
|
||||||
ObjSymbolDefines.Add(p);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TObjSection.FixupRelocs(Exe:TExeOutput);
|
procedure TObjSection.FixupRelocs(Exe:TExeOutput);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
@ -774,8 +761,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
ObjRelocations.free;
|
ObjRelocations.free;
|
||||||
ObjRelocations:=nil;
|
ObjRelocations:=nil;
|
||||||
ObjSymbolDefines.Free;
|
|
||||||
ObjSymbolDefines:=nil;
|
|
||||||
if assigned(FCachedFullName) then
|
if assigned(FCachedFullName) then
|
||||||
begin
|
begin
|
||||||
stringdispose(FCachedFullName);
|
stringdispose(FCachedFullName);
|
||||||
@ -1082,8 +1067,6 @@ implementation
|
|||||||
begin
|
begin
|
||||||
result:=TObjSymbol(asmsym.cachedObjSymbol);
|
result:=TObjSymbol(asmsym.cachedObjSymbol);
|
||||||
result.SetAddress(CurrPass,CurrObjSec,asmsym.bind,asmsym.typ);
|
result.SetAddress(CurrPass,CurrObjSec,asmsym.bind,asmsym.typ);
|
||||||
{ Register also in TObjSection }
|
|
||||||
CurrObjSec.AddSymbolDefine(result);
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1096,8 +1079,6 @@ implementation
|
|||||||
if not assigned(CurrObjSec) then
|
if not assigned(CurrObjSec) then
|
||||||
internalerror(200603051);
|
internalerror(200603051);
|
||||||
result:=CreateSymbol(aname);
|
result:=CreateSymbol(aname);
|
||||||
{ Register also in TObjSection }
|
|
||||||
CurrObjSec.AddSymbolDefine(result);
|
|
||||||
result.SetAddress(CurrPass,CurrObjSec,abind,atyp);
|
result.SetAddress(CurrPass,CurrObjSec,abind,atyp);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2346,16 +2327,34 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function ByAddress(item1,item2:pointer):longint;
|
||||||
|
var
|
||||||
|
sym1:TObjSymbol absolute item1;
|
||||||
|
sym2:TObjSymbol absolute item2;
|
||||||
|
begin
|
||||||
|
result:=sym1.address-sym2.address;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TExeOutput.PrintMemoryMap;
|
procedure TExeOutput.PrintMemoryMap;
|
||||||
var
|
var
|
||||||
exesec : TExeSection;
|
exesec : TExeSection;
|
||||||
objsec : TObjSection;
|
objsec : TObjSection;
|
||||||
objsym : TObjSymbol;
|
objsym : TObjSymbol;
|
||||||
i,j,k : longint;
|
i,j,k,m: longint;
|
||||||
|
list : TFPList;
|
||||||
|
flag : boolean;
|
||||||
begin
|
begin
|
||||||
if not assigned(exemap) then
|
if not assigned(exemap) then
|
||||||
exit;
|
exit;
|
||||||
|
{ create a list of symbols sorted by address }
|
||||||
|
list:=TFPList.Create;
|
||||||
|
for i:=0 to ExeSymbolList.Count-1 do
|
||||||
|
list.Add(TExeSymbol(ExeSymbolList[i]).ObjSymbol);
|
||||||
|
list.Sort(@ByAddress);
|
||||||
|
|
||||||
exemap.AddMemoryMapHeader(ImageBase);
|
exemap.AddMemoryMapHeader(ImageBase);
|
||||||
|
k:=0;
|
||||||
for i:=0 to ExeSectionList.Count-1 do
|
for i:=0 to ExeSectionList.Count-1 do
|
||||||
begin
|
begin
|
||||||
exesec:=TExeSection(ExeSectionList[i]);
|
exesec:=TExeSection(ExeSectionList[i]);
|
||||||
@ -2364,13 +2363,43 @@ implementation
|
|||||||
begin
|
begin
|
||||||
objsec:=TObjSection(exesec.ObjSectionList[j]);
|
objsec:=TObjSection(exesec.ObjSectionList[j]);
|
||||||
exemap.AddMemoryMapObjectSection(objsec);
|
exemap.AddMemoryMapObjectSection(objsec);
|
||||||
for k:=0 to objsec.ObjSymbolDefines.Count-1 do
|
|
||||||
|
while (k<list.Count) and (TObjSymbol(list[k]).Address<objsec.MemPos) do
|
||||||
|
inc(k);
|
||||||
|
while (k<list.Count) do
|
||||||
begin
|
begin
|
||||||
objsym:=TObjSymbol(objsec.ObjSymbolDefines[k]);
|
objsym:=TObjSymbol(list[k]);
|
||||||
exemap.AddMemoryMapSymbol(objsym);
|
if objsym.address>objsec.MemPos+objsec.Size then
|
||||||
|
break;
|
||||||
|
if objsym.objsection=objsec then
|
||||||
|
exemap.AddMemoryMapSymbol(objsym)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ Got a symbol with address falling into current section, but
|
||||||
|
belonging to a different section. This may happen for zero-length
|
||||||
|
sections because symbol list is sorted by address but not by section.
|
||||||
|
Do some look-ahead in this case. }
|
||||||
|
m:=k+1;
|
||||||
|
flag:=false;
|
||||||
|
while (m<list.Count) and (TObjSymbol(list[m]).Address=objsym.address) do
|
||||||
|
begin
|
||||||
|
if TObjSymbol(list[m]).objsection=objsec then
|
||||||
|
begin
|
||||||
|
flag:=true;
|
||||||
|
list.Exchange(k,m);
|
||||||
|
exemap.AddMemoryMapSymbol(TObjSymbol(list[k]));
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
inc(m);
|
||||||
|
end;
|
||||||
|
if not flag then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
inc(k);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
list.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1666,9 +1666,6 @@ const pemagic : array[0..3] of byte = (
|
|||||||
objsym.objsection:=objsec;
|
objsym.objsection:=objsec;
|
||||||
objsym.offset:=address;
|
objsym.offset:=address;
|
||||||
objsym.size:=size;
|
objsym.size:=size;
|
||||||
{ Register in ObjSection }
|
|
||||||
if assigned(objsec) then
|
|
||||||
objsec.AddSymbolDefine(objsym);
|
|
||||||
end;
|
end;
|
||||||
COFF_SYM_LABEL,
|
COFF_SYM_LABEL,
|
||||||
COFF_SYM_LOCAL :
|
COFF_SYM_LOCAL :
|
||||||
|
Loading…
Reference in New Issue
Block a user