mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-09 15:46:00 +02:00
Add a mechanism to keep track of assembler symbols that either publicly provided by a unit or used by a unit and that are not really baked by a Pascal symbol (e.g. public function aliases, RTTI & VMT symbol).
This basically revives the globalasmsym entry of the PPU though it feeds to different lists, one for the public (exported) symbols and one for the external (imported) symbols. Also the list of symbols is much smaller as it would be if all symbols would be dumped in there. git-svn-id: trunk@34174 -
This commit is contained in:
parent
f18e6cec0b
commit
5bb121e91c
@ -158,6 +158,8 @@ interface
|
|||||||
procinfo : TObject; { current procedure being compiled }
|
procinfo : TObject; { current procedure being compiled }
|
||||||
asmdata : TObject; { Assembler data }
|
asmdata : TObject; { Assembler data }
|
||||||
asmprefix : pshortstring; { prefix for the smartlink asmfiles }
|
asmprefix : pshortstring; { prefix for the smartlink asmfiles }
|
||||||
|
publicasmsyms : TFPHashObjectList; { contains the assembler symbols which need to be exported from a package }
|
||||||
|
externasmsyms : TFPHashObjectList; { contains the assembler symbols which are imported from another unit }
|
||||||
unitimportsyms : tfpobjectlist; { list of symbols that are imported from other units }
|
unitimportsyms : tfpobjectlist; { list of symbols that are imported from other units }
|
||||||
debuginfo : TObject;
|
debuginfo : TObject;
|
||||||
loaded_from : tmodule;
|
loaded_from : tmodule;
|
||||||
@ -237,6 +239,10 @@ interface
|
|||||||
procedure end_of_parsing;virtual;
|
procedure end_of_parsing;virtual;
|
||||||
procedure setmodulename(const s:string);
|
procedure setmodulename(const s:string);
|
||||||
procedure AddExternalImport(const libname,symname,symmangledname:string;OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
|
procedure AddExternalImport(const libname,symname,symmangledname:string;OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
|
||||||
|
procedure add_public_asmsym(sym:TAsmSymbol);
|
||||||
|
procedure add_public_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
|
||||||
|
procedure add_extern_asmsym(sym:TAsmSymbol);
|
||||||
|
procedure add_extern_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
|
||||||
property ImportLibraryList : TFPHashObjectList read FImportLibraryList;
|
property ImportLibraryList : TFPHashObjectList read FImportLibraryList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -618,6 +624,8 @@ implementation
|
|||||||
dllscannerinputlist:=TFPHashList.Create;
|
dllscannerinputlist:=TFPHashList.Create;
|
||||||
asmdata:=casmdata.create(modulename);
|
asmdata:=casmdata.create(modulename);
|
||||||
unitimportsyms:=TFPObjectList.Create(false);
|
unitimportsyms:=TFPObjectList.Create(false);
|
||||||
|
publicasmsyms:=TFPHashObjectList.Create(true);
|
||||||
|
externasmsyms:=TFPHashObjectList.Create(true);
|
||||||
InitDebugInfo(self,false);
|
InitDebugInfo(self,false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -677,6 +685,8 @@ implementation
|
|||||||
linkothersharedlibs.Free;
|
linkothersharedlibs.Free;
|
||||||
linkotherframeworks.Free;
|
linkotherframeworks.Free;
|
||||||
stringdispose(mainname);
|
stringdispose(mainname);
|
||||||
|
externasmsyms.Free;
|
||||||
|
publicasmsyms.Free;
|
||||||
unitimportsyms.Free;
|
unitimportsyms.Free;
|
||||||
FImportLibraryList.Free;
|
FImportLibraryList.Free;
|
||||||
extendeddefs.Free;
|
extendeddefs.Free;
|
||||||
@ -779,6 +789,10 @@ implementation
|
|||||||
wpoinfo:=nil;
|
wpoinfo:=nil;
|
||||||
checkforwarddefs.free;
|
checkforwarddefs.free;
|
||||||
checkforwarddefs:=TFPObjectList.Create(false);
|
checkforwarddefs:=TFPObjectList.Create(false);
|
||||||
|
publicasmsyms.free;
|
||||||
|
publicasmsyms:=TFPHashObjectList.Create(true);
|
||||||
|
externasmsyms.free;
|
||||||
|
externasmsyms:=TFPHashObjectList.Create(true);
|
||||||
unitimportsyms.free;
|
unitimportsyms.free;
|
||||||
unitimportsyms:=TFPObjectList.Create(false);
|
unitimportsyms:=TFPObjectList.Create(false);
|
||||||
derefdata.free;
|
derefdata.free;
|
||||||
@ -1153,6 +1167,50 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tmodule.add_public_asmsym(sym:TAsmSymbol);
|
||||||
|
begin
|
||||||
|
add_public_asmsym(sym.name,sym.bind,sym.typ);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tmodule.add_public_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
|
||||||
|
var
|
||||||
|
sym : tasmsymbol;
|
||||||
|
begin
|
||||||
|
{ ToDo: check for AB_GLOBAL, AB_EXTERNAL? }
|
||||||
|
sym:=tasmsymbol(publicasmsyms.find(name));
|
||||||
|
if assigned(sym) then
|
||||||
|
begin
|
||||||
|
if (sym.bind<>bind) or (sym.typ<>typ) then
|
||||||
|
internalerror(2016070101);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
tasmsymbol.create(publicasmsyms,name,bind,typ);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tmodule.add_extern_asmsym(sym:TAsmSymbol);
|
||||||
|
begin
|
||||||
|
add_extern_asmsym(sym.name,sym.bind,sym.typ);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tmodule.add_extern_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
|
||||||
|
var
|
||||||
|
sym : tasmsymbol;
|
||||||
|
begin
|
||||||
|
{ ToDo: check for AB_EXTERNAL? }
|
||||||
|
sym:=tasmsymbol(externasmsyms.find(name));
|
||||||
|
if assigned(sym) then
|
||||||
|
begin
|
||||||
|
if (sym.bind<>bind) or (sym.typ<>typ) then
|
||||||
|
internalerror(2016070102);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
tasmsymbol.create(externasmsyms,name,bind,typ);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$ifdef MEMDEBUG}
|
{$ifdef MEMDEBUG}
|
||||||
memsymtable:=TMemDebug.create('Symtables');
|
memsymtable:=TMemDebug.create('Symtables');
|
||||||
|
@ -96,6 +96,7 @@ interface
|
|||||||
procedure writeImportSymbols;
|
procedure writeImportSymbols;
|
||||||
procedure writeResources;
|
procedure writeResources;
|
||||||
procedure writeunitimportsyms;
|
procedure writeunitimportsyms;
|
||||||
|
procedure writeasmsyms(kind:tunitasmlisttype;list:tfphashobjectlist);
|
||||||
procedure readsourcefiles;
|
procedure readsourcefiles;
|
||||||
procedure readloadunit;
|
procedure readloadunit;
|
||||||
procedure readlinkcontainer(var p:tlinkcontainer);
|
procedure readlinkcontainer(var p:tlinkcontainer);
|
||||||
@ -105,6 +106,7 @@ interface
|
|||||||
procedure readResources;
|
procedure readResources;
|
||||||
procedure readwpofile;
|
procedure readwpofile;
|
||||||
procedure readunitimportsyms;
|
procedure readunitimportsyms;
|
||||||
|
procedure readasmsyms;
|
||||||
{$IFDEF MACRO_DIFF_HINT}
|
{$IFDEF MACRO_DIFF_HINT}
|
||||||
procedure writeusedmacro(p:TNamedIndexItem;arg:pointer);
|
procedure writeusedmacro(p:TNamedIndexItem;arg:pointer);
|
||||||
procedure writeusedmacros;
|
procedure writeusedmacros;
|
||||||
@ -865,6 +867,25 @@ var
|
|||||||
ppufile.writeentry(ibunitimportsyms);
|
ppufile.writeentry(ibunitimportsyms);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tppumodule.writeasmsyms(kind:tunitasmlisttype;list:tfphashobjectlist);
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
sym : TAsmSymbol;
|
||||||
|
begin
|
||||||
|
ppufile.putbyte(ord(kind));
|
||||||
|
ppufile.putlongint(list.count);
|
||||||
|
for i:=0 to list.count-1 do
|
||||||
|
begin
|
||||||
|
sym:=TAsmSymbol(list[i]);
|
||||||
|
ppufile.putstring(sym.Name);
|
||||||
|
ppufile.putbyte(ord(sym.bind));
|
||||||
|
ppufile.putbyte(ord(sym.typ));
|
||||||
|
end;
|
||||||
|
ppufile.writeentry(ibasmsymbols);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$IFDEF MACRO_DIFF_HINT}
|
{$IFDEF MACRO_DIFF_HINT}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1175,6 +1196,34 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tppumodule.readasmsyms;
|
||||||
|
var
|
||||||
|
c,i : longint;
|
||||||
|
name : TSymStr;
|
||||||
|
bind : TAsmsymbind;
|
||||||
|
typ : TAsmsymtype;
|
||||||
|
list : tfphashobjectlist;
|
||||||
|
begin
|
||||||
|
case tunitasmlisttype(ppufile.getbyte) of
|
||||||
|
ualt_public:
|
||||||
|
list:=publicasmsyms;
|
||||||
|
ualt_extern:
|
||||||
|
list:=externasmsyms;
|
||||||
|
else
|
||||||
|
internalerror(2016060301);
|
||||||
|
end;
|
||||||
|
c:=ppufile.getlongint;
|
||||||
|
for i:=0 to c-1 do
|
||||||
|
begin
|
||||||
|
name:=ppufile.getstring;
|
||||||
|
bind:=TAsmsymbind(ppufile.getbyte);
|
||||||
|
typ:=TAsmsymtype(ppufile.getbyte);
|
||||||
|
TAsmSymbol.Create(list,name,bind,typ);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tppumodule.load_interface;
|
procedure tppumodule.load_interface;
|
||||||
var
|
var
|
||||||
b : byte;
|
b : byte;
|
||||||
@ -1270,8 +1319,7 @@ var
|
|||||||
ibloadunit :
|
ibloadunit :
|
||||||
readloadunit;
|
readloadunit;
|
||||||
ibasmsymbols :
|
ibasmsymbols :
|
||||||
{ TODO: Remove ibasmsymbols}
|
readasmsyms;
|
||||||
;
|
|
||||||
ibunitimportsyms:
|
ibunitimportsyms:
|
||||||
readunitimportsyms;
|
readunitimportsyms;
|
||||||
ibendimplementation :
|
ibendimplementation :
|
||||||
@ -1418,6 +1466,12 @@ var
|
|||||||
{ write implementation uses }
|
{ write implementation uses }
|
||||||
writeusedunit(false);
|
writeusedunit(false);
|
||||||
|
|
||||||
|
{ write all public assembler symbols }
|
||||||
|
writeasmsyms(ualt_public,publicasmsyms);
|
||||||
|
|
||||||
|
{ write all external assembler symbols }
|
||||||
|
writeasmsyms(ualt_extern,externasmsyms);
|
||||||
|
|
||||||
{ write all symbols imported from another unit }
|
{ write all symbols imported from another unit }
|
||||||
writeunitimportsyms;
|
writeunitimportsyms;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ type
|
|||||||
{$endif Test_Double_checksum}
|
{$endif Test_Double_checksum}
|
||||||
|
|
||||||
const
|
const
|
||||||
CurrentPPUVersion = 184;
|
CurrentPPUVersion = 185;
|
||||||
|
|
||||||
ppubufsize = 16384;
|
ppubufsize = 16384;
|
||||||
|
|
||||||
@ -97,6 +97,8 @@ type
|
|||||||
|
|
||||||
tppuentry=tentry;
|
tppuentry=tentry;
|
||||||
|
|
||||||
|
tunitasmlisttype=(ualt_public,ualt_extern);
|
||||||
|
|
||||||
{ tppufile }
|
{ tppufile }
|
||||||
|
|
||||||
tppufile=class(tentryfile)
|
tppufile=class(tentryfile)
|
||||||
|
@ -872,6 +872,11 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Procedure ReadAsmSymbols;
|
Procedure ReadAsmSymbols;
|
||||||
|
const
|
||||||
|
unitasmlisttype: array[tunitasmlisttype] of string[6]=(
|
||||||
|
'PUBLIC',
|
||||||
|
'EXTERN'
|
||||||
|
);
|
||||||
type
|
type
|
||||||
{ Copied from aasmbase.pas }
|
{ Copied from aasmbase.pas }
|
||||||
TAsmsymbind=(
|
TAsmsymbind=(
|
||||||
@ -893,8 +898,17 @@ var
|
|||||||
bindstr,
|
bindstr,
|
||||||
typestr : string;
|
typestr : string;
|
||||||
i : longint;
|
i : longint;
|
||||||
|
t: tunitasmlisttype;
|
||||||
begin
|
begin
|
||||||
writeln([space,'Number of AsmSymbols: ',ppufile.getlongint]);
|
writeln([space,'Assembler Symbols']);
|
||||||
|
writeln([space,'-----------------']);
|
||||||
|
t:=tunitasmlisttype(ppufile.getbyte);
|
||||||
|
if (t>=Low(tunitasmlisttype)) and (t<=High(tunitasmlisttype)) then
|
||||||
|
typestr:=unitasmlisttype[t]
|
||||||
|
else
|
||||||
|
typestr:='UNKNOWN';
|
||||||
|
writeln([space,'Type: ',typestr]);
|
||||||
|
writeln([space,'Count: ',ppufile.getlongint]);
|
||||||
i:=0;
|
i:=0;
|
||||||
while (not ppufile.endofentry) and (not ppufile.error) do
|
while (not ppufile.endofentry) and (not ppufile.error) do
|
||||||
begin
|
begin
|
||||||
@ -942,6 +956,7 @@ begin
|
|||||||
Writeln([space,' ',i,' : ',s,' [',bindstr,',',typestr,']']);
|
Writeln([space,' ',i,' : ',s,' [',bindstr,',',typestr,']']);
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
|
writeln([space]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getexprint:Tconstexprint;
|
function getexprint:Tconstexprint;
|
||||||
|
Loading…
Reference in New Issue
Block a user