mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 04:19:07 +02:00
* use TFPHashObjectList instead of TDictionary
git-svn-id: trunk@3133 -
This commit is contained in:
parent
7c00500c05
commit
d542fd97fb
@ -89,7 +89,7 @@ interface
|
|||||||
|
|
||||||
TObjSectionOptions = set of TObjSectionOption;
|
TObjSectionOptions = set of TObjSectionOption;
|
||||||
|
|
||||||
TObjSymbol = class(TNamedIndexItem)
|
TObjSymbol = class(TFPHashObject)
|
||||||
public
|
public
|
||||||
bind : TAsmsymbind;
|
bind : TAsmsymbind;
|
||||||
typ : TAsmsymtype;
|
typ : TAsmsymtype;
|
||||||
@ -101,7 +101,7 @@ interface
|
|||||||
size : aint;
|
size : aint;
|
||||||
{ Used for external and common solving during linking }
|
{ Used for external and common solving during linking }
|
||||||
exesymbol : TExeSymbol;
|
exesymbol : TExeSymbol;
|
||||||
constructor create(const s:string);
|
constructor create(AList:TFPHashObjectList;const AName:string);
|
||||||
function address:aint;
|
function address:aint;
|
||||||
procedure SetAddress(apass:byte;aobjsec:TObjSection;abind:TAsmsymbind;atyp:Tasmsymtype);
|
procedure SetAddress(apass:byte;aobjsec:TObjSection;abind:TAsmsymbind;atyp:Tasmsymtype);
|
||||||
end;
|
end;
|
||||||
@ -127,7 +127,7 @@ interface
|
|||||||
constructor CreateSection(ADataOffset:aint;aobjsec:TObjSection;Atyp:TObjRelocationType);
|
constructor CreateSection(ADataOffset:aint;aobjsec:TObjSection;Atyp:TObjRelocationType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TObjSection = class(TNamedIndexItem)
|
TObjSection = class(TFPHashObject)
|
||||||
private
|
private
|
||||||
FData : TDynamicArray;
|
FData : TDynamicArray;
|
||||||
FSecOptions : TObjSectionOptions;
|
FSecOptions : TObjSectionOptions;
|
||||||
@ -149,7 +149,7 @@ interface
|
|||||||
ExeSection : TExeSection;
|
ExeSection : TExeSection;
|
||||||
Used : boolean;
|
Used : boolean;
|
||||||
VTRefList : TFPObjectList;
|
VTRefList : TFPObjectList;
|
||||||
constructor create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);virtual;
|
constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);virtual;
|
||||||
destructor destroy;override;
|
destructor destroy;override;
|
||||||
function write(const d;l:aint):aint;
|
function write(const d;l:aint):aint;
|
||||||
function writestr(const s:string):aint;
|
function writestr(const s:string):aint;
|
||||||
@ -172,14 +172,10 @@ interface
|
|||||||
private
|
private
|
||||||
FName : string[80];
|
FName : string[80];
|
||||||
FCurrObjSec : TObjSection;
|
FCurrObjSec : TObjSection;
|
||||||
{ ObjSections will be stored in order in SectsIndex, this is at least
|
FObjSectionList : TFPHashObjectList;
|
||||||
required for stabs debuginfo. The SectsDict is only used for lookups (PFV) }
|
|
||||||
FObjSectionDict : TDictionary;
|
|
||||||
FObjSectionList : TFPObjectList;
|
|
||||||
FCObjSection : TObjSectionClass;
|
FCObjSection : TObjSectionClass;
|
||||||
{ Symbols that will be defined in this object file }
|
{ Symbols that will be defined in this object file }
|
||||||
FObjSymbolList : TFPObjectList;
|
FObjSymbolList : TFPHashObjectList;
|
||||||
FObjSymbolDict : TDictionary;
|
|
||||||
FCachedAsmSymbolList : TFPObjectList;
|
FCachedAsmSymbolList : TFPObjectList;
|
||||||
{ Special info sections that are written to during object generation }
|
{ Special info sections that are written to during object generation }
|
||||||
FStabsObjSec,
|
FStabsObjSec,
|
||||||
@ -226,8 +222,8 @@ interface
|
|||||||
procedure resetsections;
|
procedure resetsections;
|
||||||
property Name:string[80] read FName;
|
property Name:string[80] read FName;
|
||||||
property CurrObjSec:TObjSection read FCurrObjSec;
|
property CurrObjSec:TObjSection read FCurrObjSec;
|
||||||
property ObjSymbolList:TFPObjectList read FObjSymbolList;
|
property ObjSymbolList:TFPHashObjectList read FObjSymbolList;
|
||||||
property ObjSectionList:TFPObjectList read FObjSectionList;
|
property ObjSectionList:TFPHashObjectList read FObjSectionList;
|
||||||
end;
|
end;
|
||||||
TObjDataClass = class of TObjData;
|
TObjDataClass = class of TObjData;
|
||||||
|
|
||||||
@ -293,15 +289,14 @@ interface
|
|||||||
function VTableRef(VTableIdx:Longint):TObjRelocation;
|
function VTableRef(VTableIdx:Longint):TObjRelocation;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TExeSymbol = class(TNamedIndexItem)
|
TExeSymbol = class(TFPHashObject)
|
||||||
ObjSymbol : TObjSymbol;
|
ObjSymbol : TObjSymbol;
|
||||||
ExeSection : TExeSection;
|
ExeSection : TExeSection;
|
||||||
{ Used for vmt references optimization }
|
{ Used for vmt references optimization }
|
||||||
VTable : TExeVTable;
|
VTable : TExeVTable;
|
||||||
constructor create(sym:TObjSymbol);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TExeSection = class(tnamedindexitem)
|
TExeSection = class(TFPHashObject)
|
||||||
private
|
private
|
||||||
FSecSymIdx : longint;
|
FSecSymIdx : longint;
|
||||||
FObjSectionList : TFPObjectList;
|
FObjSectionList : TFPObjectList;
|
||||||
@ -311,7 +306,7 @@ interface
|
|||||||
MemPos : aint;
|
MemPos : aint;
|
||||||
SecAlign : shortint;
|
SecAlign : shortint;
|
||||||
SecOptions : TObjSectionOptions;
|
SecOptions : TObjSectionOptions;
|
||||||
constructor create(const n:string);virtual;
|
constructor create(AList:TFPHashObjectList;const AName:string);virtual;
|
||||||
destructor destroy;override;
|
destructor destroy;override;
|
||||||
procedure AddObjSection(objsec:TObjSection);
|
procedure AddObjSection(objsec:TObjSection);
|
||||||
property ObjSectionList:TFPObjectList read FObjSectionList;
|
property ObjSectionList:TFPObjectList read FObjSectionList;
|
||||||
@ -325,12 +320,10 @@ interface
|
|||||||
FCObjData : TObjDataClass;
|
FCObjData : TObjDataClass;
|
||||||
FCExeSection : TExeSectionClass;
|
FCExeSection : TExeSectionClass;
|
||||||
FCurrExeSec : TExeSection;
|
FCurrExeSec : TExeSection;
|
||||||
FExeSectionList : TFPObjectList;
|
FExeSectionList : TFPHashObjectList;
|
||||||
FExeSectionDict : TDictionary;
|
|
||||||
Fzeronr : longint;
|
Fzeronr : longint;
|
||||||
{ Symbols }
|
{ Symbols }
|
||||||
FExeSymbolDict : TDictionary;
|
FExeSymbolList : TFPHashObjectList;
|
||||||
FExeSymbolList,
|
|
||||||
FUnresolvedExeSymbols : TFPObjectList;
|
FUnresolvedExeSymbols : TFPObjectList;
|
||||||
FExternalObjSymbols,
|
FExternalObjSymbols,
|
||||||
FCommonObjSymbols : TFPObjectList;
|
FCommonObjSymbols : TFPObjectList;
|
||||||
@ -385,10 +378,9 @@ interface
|
|||||||
procedure ResolveExternals(const libname:string);virtual;
|
procedure ResolveExternals(const libname:string);virtual;
|
||||||
function writeexefile(const fn:string):boolean;
|
function writeexefile(const fn:string):boolean;
|
||||||
property Writer:TObjectWriter read FWriter;
|
property Writer:TObjectWriter read FWriter;
|
||||||
property ExeSections:TFPObjectList read FExeSectionList;
|
property ExeSections:TFPHashObjectList read FExeSectionList;
|
||||||
property ObjDataList:TFPObjectList read FObjDataList;
|
property ObjDataList:TFPObjectList read FObjDataList;
|
||||||
property ExeSymbolDict:TDictionary read FExeSymbolDict;
|
property ExeSymbolList:TFPHashObjectList read FExeSymbolList;
|
||||||
property ExeSymbolList:TFPObjectList read FExeSymbolList;
|
|
||||||
property UnresolvedExeSymbols:TFPObjectList read FUnresolvedExeSymbols;
|
property UnresolvedExeSymbols:TFPObjectList read FUnresolvedExeSymbols;
|
||||||
property ExternalObjSymbols:TFPObjectList read FExternalObjSymbols;
|
property ExternalObjSymbols:TFPObjectList read FExternalObjSymbols;
|
||||||
property CommonObjSymbols:TFPObjectList read FCommonObjSymbols;
|
property CommonObjSymbols:TFPObjectList read FCommonObjSymbols;
|
||||||
@ -411,16 +403,21 @@ implementation
|
|||||||
cutils,globals,verbose,fmodule,ogmap;
|
cutils,globals,verbose,fmodule,ogmap;
|
||||||
|
|
||||||
const
|
const
|
||||||
sectionDatagrowsize = 1024;
|
sectionDatagrowsize = 256-sizeof(ptrint);
|
||||||
|
|
||||||
|
{$ifdef MEMDEBUG}
|
||||||
|
var
|
||||||
|
memobjsymbols,
|
||||||
|
memobjsections : TMemDebug;
|
||||||
|
{$endif MEMDEBUG}
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
TObjSymbol
|
TObjSymbol
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
constructor TObjSymbol.create(const s:string);
|
constructor TObjSymbol.create(AList:TFPHashObjectList;const AName:string);
|
||||||
begin;
|
begin;
|
||||||
inherited createname(s);
|
inherited create(AList,AName);
|
||||||
bind:=AB_EXTERNAL;
|
bind:=AB_EXTERNAL;
|
||||||
typ:=AT_NONE;
|
typ:=AT_NONE;
|
||||||
symidx:=-1;
|
symidx:=-1;
|
||||||
@ -508,10 +505,9 @@ implementation
|
|||||||
TObjSection
|
TObjSection
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor TObjSection.create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);
|
constructor TObjSection.create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);
|
||||||
begin
|
begin
|
||||||
inherited createname(Aname);
|
inherited Create(AList,Aname);
|
||||||
name:=Aname;
|
|
||||||
{ Data }
|
{ Data }
|
||||||
Size:=0;
|
Size:=0;
|
||||||
Datapos:=0;
|
Datapos:=0;
|
||||||
@ -670,17 +666,11 @@ implementation
|
|||||||
begin
|
begin
|
||||||
inherited create;
|
inherited create;
|
||||||
FName:=SplitFileName(n);
|
FName:=SplitFileName(n);
|
||||||
{ sections, the SectsIndex owns the items, the FObjSectionDict
|
FObjSectionList:=TFPHashObjectList.Create(true);
|
||||||
is only used for lookups }
|
|
||||||
FObjSectionDict:=tdictionary.create;
|
|
||||||
FObjSectionDict.noclear:=true;
|
|
||||||
FObjSectionList:=TFPObjectList.Create(true);
|
|
||||||
FStabsObjSec:=nil;
|
FStabsObjSec:=nil;
|
||||||
FStabStrObjSec:=nil;
|
FStabStrObjSec:=nil;
|
||||||
{ symbols }
|
{ symbols }
|
||||||
FObjSymbolDict:=tdictionary.create;
|
FObjSymbolList:=TFPHashObjectList.Create(true);
|
||||||
FObjSymbolDict.noclear:=true;
|
|
||||||
FObjSymbolList:=TFPObjectList.Create(true);
|
|
||||||
FCachedAsmSymbolList:=TFPObjectList.Create(false);
|
FCachedAsmSymbolList:=TFPObjectList.Create(false);
|
||||||
{ section class type for creating of new sections }
|
{ section class type for creating of new sections }
|
||||||
FCObjSection:=TObjSection;
|
FCObjSection:=TObjSection;
|
||||||
@ -695,20 +685,22 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{$ifdef MEMDEBUG}
|
{$ifdef MEMDEBUG}
|
||||||
d:=tmemdebug.create(name+' - ObjData symbols');
|
d:=tmemdebug.create(name+' - ObjData symbols');
|
||||||
|
MemObjSymbols.Start;
|
||||||
{$endif}
|
{$endif}
|
||||||
ResetCachedAsmSymbols;
|
ResetCachedAsmSymbols;
|
||||||
FCachedAsmSymbolList.free;
|
FCachedAsmSymbolList.free;
|
||||||
FObjSymbolDict.free;
|
|
||||||
FObjSymbolList.free;
|
FObjSymbolList.free;
|
||||||
{$ifdef MEMDEBUG}
|
{$ifdef MEMDEBUG}
|
||||||
|
MemObjSymbols.Stop;
|
||||||
d.free;
|
d.free;
|
||||||
{$endif}
|
{$endif}
|
||||||
{$ifdef MEMDEBUG}
|
{$ifdef MEMDEBUG}
|
||||||
d:=tmemdebug.create(name+' - ObjData sections');
|
d:=tmemdebug.create(name+' - ObjData sections');
|
||||||
|
MemObjSections.Start;
|
||||||
{$endif}
|
{$endif}
|
||||||
FObjSectionDict.free;
|
|
||||||
FObjSectionList.free;
|
FObjSectionList.free;
|
||||||
{$ifdef MEMDEBUG}
|
{$ifdef MEMDEBUG}
|
||||||
|
MemObjSections.Stop;
|
||||||
d.free;
|
d.free;
|
||||||
{$endif}
|
{$endif}
|
||||||
inherited destroy;
|
inherited destroy;
|
||||||
@ -788,12 +780,10 @@ implementation
|
|||||||
|
|
||||||
function TObjData.createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions):TObjSection;
|
function TObjData.createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions):TObjSection;
|
||||||
begin
|
begin
|
||||||
result:=TObjSection(FObjSectionDict.search(aname));
|
result:=TObjSection(FObjSectionList.Find(aname));
|
||||||
if not assigned(result) then
|
if not assigned(result) then
|
||||||
begin
|
begin
|
||||||
result:=CObjSection.create(aname,aalign,aoptions);
|
result:=CObjSection.create(FObjSectionList,aname,aalign,aoptions);
|
||||||
FObjSectionDict.Insert(result);
|
|
||||||
FObjSectionList.Add(result);
|
|
||||||
result.ObjData:=self;
|
result.ObjData:=self;
|
||||||
end;
|
end;
|
||||||
FCurrObjSec:=result;
|
FCurrObjSec:=result;
|
||||||
@ -807,7 +797,7 @@ implementation
|
|||||||
|
|
||||||
function TObjData.FindSection(const aname:string):TObjSection;
|
function TObjData.FindSection(const aname:string):TObjSection;
|
||||||
begin
|
begin
|
||||||
result:=TObjSection(FObjSectionDict.Search(aname));
|
result:=TObjSection(FObjSectionList.Find(aname));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -821,13 +811,9 @@ implementation
|
|||||||
|
|
||||||
function TObjData.createsymbol(const aname:string):TObjSymbol;
|
function TObjData.createsymbol(const aname:string):TObjSymbol;
|
||||||
begin
|
begin
|
||||||
result:=TObjSymbol(FObjSymbolDict.search(aname));
|
result:=TObjSymbol(FObjSymbolList.Find(aname));
|
||||||
if not assigned(result) then
|
if not assigned(result) then
|
||||||
begin
|
result:=TObjSymbol.Create(FObjSymbolList,aname);
|
||||||
result:=TObjSymbol.Create(aname);
|
|
||||||
FObjSymbolDict.Insert(result);
|
|
||||||
FObjSymbolList.Add(result);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1173,23 +1159,12 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
TExeSymbol
|
TExeSection
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor TExeSymbol.create(sym:TObjSymbol);
|
constructor TExeSection.create(AList:TFPHashObjectList;const AName:string);
|
||||||
begin
|
begin
|
||||||
inherited createname(sym.name);
|
inherited create(AList,AName);
|
||||||
ObjSymbol:=sym;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
|
||||||
tExeSection
|
|
||||||
****************************************************************************}
|
|
||||||
|
|
||||||
constructor tExeSection.create(const n:string);
|
|
||||||
begin
|
|
||||||
inherited createname(n);
|
|
||||||
Size:=0;
|
Size:=0;
|
||||||
MemPos:=0;
|
MemPos:=0;
|
||||||
DataPos:=0;
|
DataPos:=0;
|
||||||
@ -1198,14 +1173,14 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
destructor tExeSection.destroy;
|
destructor TExeSection.destroy;
|
||||||
begin
|
begin
|
||||||
ObjSectionList.Free;
|
ObjSectionList.Free;
|
||||||
inherited destroy;
|
inherited destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tExeSection.AddObjSection(objsec:TObjSection);
|
procedure TExeSection.AddObjSection(objsec:TObjSection);
|
||||||
begin
|
begin
|
||||||
ObjSectionList.Add(objsec);
|
ObjSectionList.Add(objsec);
|
||||||
if (SecOptions<>[]) then
|
if (SecOptions<>[]) then
|
||||||
@ -1236,19 +1211,14 @@ implementation
|
|||||||
{ object files }
|
{ object files }
|
||||||
FObjDataList:=TFPObjectList.Create(true);
|
FObjDataList:=TFPObjectList.Create(true);
|
||||||
{ symbols }
|
{ symbols }
|
||||||
FExeSymbolDict:=tdictionary.create;
|
FExeSymbolList:=TFPHashObjectList.Create(true);
|
||||||
FExeSymbolDict.noclear:=true;
|
|
||||||
FExeSymbolDict.usehash;
|
|
||||||
FExeSymbolList:=TFPObjectList.Create(true);
|
|
||||||
FUnresolvedExeSymbols:=TFPObjectList.Create(false);
|
FUnresolvedExeSymbols:=TFPObjectList.Create(false);
|
||||||
FExternalObjSymbols:=TFPObjectList.Create(false);
|
FExternalObjSymbols:=TFPObjectList.Create(false);
|
||||||
FCommonObjSymbols:=TFPObjectList.Create(false);
|
FCommonObjSymbols:=TFPObjectList.Create(false);
|
||||||
FExeVTableList:=TFPObjectList.Create(false);
|
FExeVTableList:=TFPObjectList.Create(false);
|
||||||
FEntryName:='start';
|
FEntryName:='start';
|
||||||
{ sections }
|
{ sections }
|
||||||
FExeSectionDict:=TDictionary.create;
|
FExeSectionList:=TFPHashObjectList.Create(true);
|
||||||
FExeSectionDict.noclear:=true;
|
|
||||||
FExeSectionList:=TFPObjectList.Create(true);
|
|
||||||
FImageBase:=0;
|
FImageBase:=0;
|
||||||
SectionMemAlign:=$1000;
|
SectionMemAlign:=$1000;
|
||||||
SectionDataAlign:=$200;
|
SectionDataAlign:=$200;
|
||||||
@ -1259,13 +1229,11 @@ implementation
|
|||||||
|
|
||||||
destructor TExeOutput.destroy;
|
destructor TExeOutput.destroy;
|
||||||
begin
|
begin
|
||||||
FExeSymbolDict.free;
|
|
||||||
FExeSymbolList.free;
|
FExeSymbolList.free;
|
||||||
UnresolvedExeSymbols.free;
|
UnresolvedExeSymbols.free;
|
||||||
ExternalObjSymbols.free;
|
ExternalObjSymbols.free;
|
||||||
CommonObjSymbols.free;
|
CommonObjSymbols.free;
|
||||||
ExeVTableList.free;
|
ExeVTableList.free;
|
||||||
FExeSectionDict.free;
|
|
||||||
FExeSectionList.free;
|
FExeSectionList.free;
|
||||||
ObjDatalist.free;
|
ObjDatalist.free;
|
||||||
FWriter.free;
|
FWriter.free;
|
||||||
@ -1301,7 +1269,7 @@ implementation
|
|||||||
|
|
||||||
function TExeOutput.FindExeSection(const aname:string):TExeSection;
|
function TExeOutput.FindExeSection(const aname:string):TExeSection;
|
||||||
begin
|
begin
|
||||||
result:=TExeSection(FExeSectionDict.Search(aname));
|
result:=TExeSection(FExeSectionList.Find(aname));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1347,11 +1315,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
sec:=FindExeSection(aname);
|
sec:=FindExeSection(aname);
|
||||||
if not assigned(sec) then
|
if not assigned(sec) then
|
||||||
begin
|
sec:=CExeSection.create(FExeSectionList,aname);
|
||||||
sec:=CExeSection.create(aname);
|
|
||||||
FExeSectionDict.Insert(sec);
|
|
||||||
FExeSectionList.Add(sec);
|
|
||||||
end;
|
|
||||||
{ Clear ExeSection contents }
|
{ Clear ExeSection contents }
|
||||||
FCurrExeSec:=sec;
|
FCurrExeSec:=sec;
|
||||||
end;
|
end;
|
||||||
@ -1401,7 +1365,7 @@ implementation
|
|||||||
procedure TExeOutput.Order_Align(const aname:string);
|
procedure TExeOutput.Order_Align(const aname:string);
|
||||||
var
|
var
|
||||||
code : integer;
|
code : integer;
|
||||||
alignval : longint;
|
alignval : shortint;
|
||||||
objsec : TObjSection;
|
objsec : TObjSection;
|
||||||
begin
|
begin
|
||||||
val(aname,alignval,code);
|
val(aname,alignval,code);
|
||||||
@ -1521,8 +1485,8 @@ implementation
|
|||||||
k:=Pos('$$',hs);
|
k:=Pos('$$',hs);
|
||||||
if k=0 then
|
if k=0 then
|
||||||
internalerror(200603311);
|
internalerror(200603311);
|
||||||
childexesym:=texesymbol(FExeSymbolDict.search(Copy(hs,1,k-1)));
|
childexesym:=texesymbol(FExeSymbolList.Find(Copy(hs,1,k-1)));
|
||||||
parentexesym:=texesymbol(FExeSymbolDict.search(Copy(hs,k+2,length(hs)-k-1)));
|
parentexesym:=texesymbol(FExeSymbolList.Find(Copy(hs,k+2,length(hs)-k-1)));
|
||||||
if not assigned(childexesym) or
|
if not assigned(childexesym) or
|
||||||
not assigned(parentexesym)then
|
not assigned(parentexesym)then
|
||||||
internalerror(200603312);
|
internalerror(200603312);
|
||||||
@ -1551,7 +1515,7 @@ implementation
|
|||||||
k:=Pos('$$',hs);
|
k:=Pos('$$',hs);
|
||||||
if k=0 then
|
if k=0 then
|
||||||
internalerror(200603319);
|
internalerror(200603319);
|
||||||
vtableexesym:=texesymbol(FExeSymbolDict.search(Copy(hs,1,k-1)));
|
vtableexesym:=texesymbol(FExeSymbolList.Find(Copy(hs,1,k-1)));
|
||||||
val(Copy(hs,k+2,length(hs)-k-1),vtableidx,code);
|
val(Copy(hs,k+2,length(hs)-k-1),vtableidx,code);
|
||||||
if (code<>0) then
|
if (code<>0) then
|
||||||
internalerror(200603318);
|
internalerror(200603318);
|
||||||
@ -1618,13 +1582,9 @@ implementation
|
|||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
{ Search for existing exesymbol }
|
{ Search for existing exesymbol }
|
||||||
exesym:=texesymbol(FExeSymbolDict.search(objsym.name));
|
exesym:=texesymbol(FExeSymbolList.Find(objsym.name));
|
||||||
if not assigned(exesym) then
|
if not assigned(exesym) then
|
||||||
begin
|
exesym:=texesymbol.Create(FExeSymbolList,objsym.name);
|
||||||
exesym:=texesymbol.createname(objsym.name);
|
|
||||||
FExeSymbolDict.insert(exesym);
|
|
||||||
FExeSymbolList.Add(exesym);
|
|
||||||
end;
|
|
||||||
{ Defining the symbol? }
|
{ Defining the symbol? }
|
||||||
if objsym.bind=AB_GLOBAL then
|
if objsym.bind=AB_GLOBAL then
|
||||||
begin
|
begin
|
||||||
@ -1684,7 +1644,7 @@ implementation
|
|||||||
Comment(V_Debug,'Number of unresolved externals in objects '+tostr(UnresolvedExeSymbols.Count));
|
Comment(V_Debug,'Number of unresolved externals in objects '+tostr(UnresolvedExeSymbols.Count));
|
||||||
|
|
||||||
{ Find entry symbol and print in map }
|
{ Find entry symbol and print in map }
|
||||||
exesym:=texesymbol(ExeSymbolDict.search(EntryName));
|
exesym:=texesymbol(ExeSymbolList.Find(EntryName));
|
||||||
if assigned(exesym) then
|
if assigned(exesym) then
|
||||||
begin
|
begin
|
||||||
EntrySym:=exesym.ObjSymbol;
|
EntrySym:=exesym.ObjSymbol;
|
||||||
@ -1964,8 +1924,7 @@ implementation
|
|||||||
) then
|
) then
|
||||||
begin
|
begin
|
||||||
Comment(V_Debug,'Deleting empty section '+exesec.name);
|
Comment(V_Debug,'Deleting empty section '+exesec.name);
|
||||||
FExeSectionDict.Delete(exesec.name);
|
FExeSectionList.Delete(i);
|
||||||
FExeSectionList[i]:=nil;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ExeSections.Pack;
|
ExeSections.Pack;
|
||||||
@ -2097,7 +2056,7 @@ implementation
|
|||||||
k:=Pos('$$',hs);
|
k:=Pos('$$',hs);
|
||||||
if k=0 then
|
if k=0 then
|
||||||
internalerror(200603314);
|
internalerror(200603314);
|
||||||
vtableexesym:=texesymbol(FExeSymbolDict.search(Copy(hs,1,k-1)));
|
vtableexesym:=texesymbol(FExeSymbolList.Find(Copy(hs,1,k-1)));
|
||||||
val(Copy(hs,k+2,length(hs)-k-1),vtableidx,code);
|
val(Copy(hs,k+2,length(hs)-k-1),vtableidx,code);
|
||||||
if (code<>0) then
|
if (code<>0) then
|
||||||
internalerror(200603317);
|
internalerror(200603317);
|
||||||
@ -2141,6 +2100,8 @@ implementation
|
|||||||
for i:=0 to ExeSections.Count-1 do
|
for i:=0 to ExeSections.Count-1 do
|
||||||
begin
|
begin
|
||||||
exesec:=TExeSection(ExeSections[i]);
|
exesec:=TExeSection(ExeSections[i]);
|
||||||
|
if not assigned(exesec) then
|
||||||
|
continue;
|
||||||
for j:=0 to exesec.ObjSectionlist.count-1 do
|
for j:=0 to exesec.ObjSectionlist.count-1 do
|
||||||
begin
|
begin
|
||||||
objsec:=TObjSection(exesec.ObjSectionlist[j]);
|
objsec:=TObjSection(exesec.ObjSectionlist[j]);
|
||||||
@ -2192,4 +2153,16 @@ implementation
|
|||||||
Comment(V_Error,s+' while reading '+reader.filename);
|
Comment(V_Error,s+' while reading '+reader.filename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$ifdef MEMDEBUG}
|
||||||
|
initialization
|
||||||
|
memobjsymbols:=TMemDebug.create('ObjSymbols');
|
||||||
|
memobjsymbols.stop;
|
||||||
|
memobjsections:=TMemDebug.create('ObjSections');
|
||||||
|
memobjsections.stop;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
memobjsymbols.free;
|
||||||
|
memobjsections.free;
|
||||||
|
{$endif MEMDEBUG}
|
||||||
end.
|
end.
|
||||||
|
@ -45,17 +45,17 @@ interface
|
|||||||
public
|
public
|
||||||
secidx : longint;
|
secidx : longint;
|
||||||
flags : longword;
|
flags : longword;
|
||||||
constructor create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
||||||
procedure addsymsizereloc(ofs:aint;p:TObjSymbol;symsize:aint;reloctype:TObjRelocationType);
|
procedure addsymsizereloc(ofs:aint;p:TObjSymbol;symsize:aint;reloctype:TObjRelocationType);
|
||||||
procedure fixuprelocs;override;
|
procedure fixuprelocs;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TDJCoffObjSection = class(TCoffObjSection)
|
TDJCoffObjSection = class(TCoffObjSection)
|
||||||
constructor create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TPECoffObjSection = class(TCoffObjSection)
|
TPECoffObjSection = class(TCoffObjSection)
|
||||||
constructor create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCoffObjData = class(TObjData)
|
TCoffObjData = class(TObjData)
|
||||||
@ -143,15 +143,15 @@ interface
|
|||||||
private
|
private
|
||||||
win32 : boolean;
|
win32 : boolean;
|
||||||
public
|
public
|
||||||
constructor createcoff(const n:string;awin32:boolean);
|
constructor createcoff(AList:TFPHashObjectList;const n:string;awin32:boolean);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TDJCoffExeSection = class(TCoffExeSection)
|
TDJCoffExeSection = class(TCoffExeSection)
|
||||||
constructor create(const n:string);override;
|
constructor create(AList:TFPHashObjectList;const n:string);override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TPECoffExeSection = class(TCoffExeSection)
|
TPECoffExeSection = class(TCoffExeSection)
|
||||||
constructor create(const n:string);override;
|
constructor create(AList:TFPHashObjectList;const n:string);override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCoffexeoutput = class(texeoutput)
|
TCoffexeoutput = class(texeoutput)
|
||||||
@ -721,9 +721,9 @@ const win32stub : array[0..131] of byte=(
|
|||||||
TCoffObjSection
|
TCoffObjSection
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor TCoffObjSection.create(const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
|
constructor TCoffObjSection.create(AList:TFPHashObjectList;const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
|
||||||
begin
|
begin
|
||||||
inherited create(aname,aalign,aoptions);
|
inherited create(AList,aname,aalign,aoptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -816,9 +816,9 @@ const win32stub : array[0..131] of byte=(
|
|||||||
TDJCoffObjSection
|
TDJCoffObjSection
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor TDJCoffObjSection.create(const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
|
constructor TDJCoffObjSection.create(AList:TFPHashObjectList;const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
|
||||||
begin
|
begin
|
||||||
inherited create(aname,aalign,aoptions);
|
inherited create(alist,aname,aalign,aoptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -826,9 +826,9 @@ const win32stub : array[0..131] of byte=(
|
|||||||
TPECoffObjSection
|
TPECoffObjSection
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor TPECoffObjSection.create(const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
|
constructor TPECoffObjSection.create(AList:TFPHashObjectList;const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
|
||||||
begin
|
begin
|
||||||
inherited create(aname,aalign,aoptions);
|
inherited create(alist,aname,aalign,aoptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1783,22 +1783,22 @@ const win32stub : array[0..131] of byte=(
|
|||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
|
|
||||||
constructor TCoffExeSection.createcoff(const n:string;awin32:boolean);
|
constructor TCoffExeSection.createcoff(AList:TFPHashObjectList;const n:string;awin32:boolean);
|
||||||
begin
|
begin
|
||||||
inherited create(n);
|
inherited create(AList,n);
|
||||||
win32:=awin32;
|
win32:=awin32;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor TDJCoffExeSection.create(const n:string);
|
constructor TDJCoffExeSection.create(AList:TFPHashObjectList;const n:string);
|
||||||
begin
|
begin
|
||||||
inherited createcoff(n,false);
|
inherited createcoff(AList,n,false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor TPECoffExeSection.create(const n:string);
|
constructor TPECoffExeSection.create(AList:TFPHashObjectList;const n:string);
|
||||||
begin
|
begin
|
||||||
inherited createcoff(n,false);
|
inherited createcoff(AList,n,false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ interface
|
|||||||
shentsize : longint;
|
shentsize : longint;
|
||||||
{ relocation }
|
{ relocation }
|
||||||
relocsect : TElfObjSection;
|
relocsect : TElfObjSection;
|
||||||
constructor create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
|
||||||
constructor create_ext(const Aname:string;Ashtype,Ashflags,Ashlink,Ashinfo:longint;Aalign:shortint;Aentsize:longint);
|
constructor create_ext(AList:TFPHashObjectList;const Aname:string;Ashtype,Ashflags,Ashlink,Ashinfo:longint;Aalign:shortint;Aentsize:longint);
|
||||||
destructor destroy;override;
|
destructor destroy;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -517,9 +517,9 @@ implementation
|
|||||||
TSection
|
TSection
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor TElfObjSection.create(const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);
|
constructor TElfObjSection.create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);
|
||||||
begin
|
begin
|
||||||
inherited create(Aname,Aalign,aoptions);
|
inherited create(AList,Aname,Aalign,aoptions);
|
||||||
secshidx:=0;
|
secshidx:=0;
|
||||||
shstridx:=0;
|
shstridx:=0;
|
||||||
encodesechdrflags(aoptions,shtype,shflags);
|
encodesechdrflags(aoptions,shtype,shflags);
|
||||||
@ -531,12 +531,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor TElfObjSection.create_ext(const Aname:string;Ashtype,Ashflags,Ashlink,Ashinfo:longint;Aalign:shortint;Aentsize:longint);
|
constructor TElfObjSection.create_ext(AList:TFPHashObjectList;const Aname:string;Ashtype,Ashflags,Ashlink,Ashinfo:longint;Aalign:shortint;Aentsize:longint);
|
||||||
var
|
var
|
||||||
aoptions : TObjSectionOptions;
|
aoptions : TObjSectionOptions;
|
||||||
begin
|
begin
|
||||||
decodesechdrflags(Ashtype,Ashflags,aoptions);
|
decodesechdrflags(Ashtype,Ashflags,aoptions);
|
||||||
inherited create(Aname,Aalign,aoptions);
|
inherited create(AList,Aname,Aalign,aoptions);
|
||||||
secshidx:=0;
|
secshidx:=0;
|
||||||
shstridx:=0;
|
shstridx:=0;
|
||||||
shtype:=AshType;
|
shtype:=AshType;
|
||||||
@ -565,9 +565,9 @@ implementation
|
|||||||
inherited create(n);
|
inherited create(n);
|
||||||
CObjSection:=TElfObjSection;
|
CObjSection:=TElfObjSection;
|
||||||
{ default sections }
|
{ default sections }
|
||||||
symtabsect:=TElfObjSection.create_ext('.symtab',SHT_SYMTAB,0,0,0,4,sizeof(telfsymbol));
|
symtabsect:=TElfObjSection.create_ext(ObjSectionList,'.symtab',SHT_SYMTAB,0,0,0,4,sizeof(telfsymbol));
|
||||||
strtabsect:=TElfObjSection.create_ext('.strtab',SHT_STRTAB,0,0,0,1,0);
|
strtabsect:=TElfObjSection.create_ext(ObjSectionList,'.strtab',SHT_STRTAB,0,0,0,1,0);
|
||||||
shstrtabsect:=TElfObjSection.create_ext('.shstrtab',SHT_STRTAB,0,0,0,1,0);
|
shstrtabsect:=TElfObjSection.create_ext(ObjSectionList,'.shstrtab',SHT_STRTAB,0,0,0,1,0);
|
||||||
{ insert the empty and filename as first in strtab }
|
{ insert the empty and filename as first in strtab }
|
||||||
strtabsect.writestr(#0);
|
strtabsect.writestr(#0);
|
||||||
strtabsect.writestr(SplitFileName(current_module.mainsource^)+#0);
|
strtabsect.writestr(SplitFileName(current_module.mainsource^)+#0);
|
||||||
@ -725,9 +725,9 @@ implementation
|
|||||||
{$endif userodata}
|
{$endif userodata}
|
||||||
{ create the reloc section }
|
{ create the reloc section }
|
||||||
{$ifdef i386}
|
{$ifdef i386}
|
||||||
s.relocsect:=TElfObjSection.create_ext('.rel'+s.name,SHT_REL,0,symtabsect.secshidx,s.secshidx,4,sizeof(TElfReloc));
|
s.relocsect:=TElfObjSection.create_ext(ObjSectionList,'.rel'+s.name,SHT_REL,0,symtabsect.secshidx,s.secshidx,4,sizeof(TElfReloc));
|
||||||
{$else i386}
|
{$else i386}
|
||||||
s.relocsect:=TElfObjSection.create_ext('.rela'+s.name,SHT_RELA,0,symtabsect.secshidx,s.secshidx,4,sizeof(TElfReloc));
|
s.relocsect:=TElfObjSection.create_ext(ObjSectionList,'.rela'+s.name,SHT_RELA,0,symtabsect.secshidx,s.secshidx,4,sizeof(TElfReloc));
|
||||||
{$endif i386}
|
{$endif i386}
|
||||||
{ add the relocations }
|
{ add the relocations }
|
||||||
for i:=0 to s.Objrelocations.count-1 do
|
for i:=0 to s.Objrelocations.count-1 do
|
||||||
|
Loading…
Reference in New Issue
Block a user