mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 07:26:18 +02:00
* factored out checks whether a procdef's symbol needs to be global, and
the generation of the procdef's asmsymbols o also removed unnecessary definition of procdef alias symbols for Darwin (they are already defined in ncgutil.alloc_proc_symbol) git-svn-id: trunk@42341 -
This commit is contained in:
parent
3fee990218
commit
e56b58c2b0
@ -198,6 +198,7 @@ interface
|
|||||||
{ asmsymbol }
|
{ asmsymbol }
|
||||||
function DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; virtual;
|
function DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; virtual;
|
||||||
function DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol;
|
function DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol;
|
||||||
|
function DefineProcAsmSymbol(pd: tdef; const s: TSymStr; global: boolean): TAsmSymbol;
|
||||||
function WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
|
function WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
|
||||||
function RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean=false) : TAsmSymbol;
|
function RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean=false) : TAsmSymbol;
|
||||||
function GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
|
function GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
|
||||||
@ -248,6 +249,7 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
verbose,
|
verbose,
|
||||||
|
globals,
|
||||||
symconst,
|
symconst,
|
||||||
aasmtai;
|
aasmtai;
|
||||||
|
|
||||||
@ -572,6 +574,21 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TAsmData.DefineProcAsmSymbol(pd: tdef; const s: TSymStr; global: boolean): TAsmSymbol;
|
||||||
|
begin
|
||||||
|
{ The condition to use global or local symbol must match
|
||||||
|
the code written in hlcg.gen_proc_symbol to
|
||||||
|
avoid change from AB_LOCAL to AB_GLOBAL, which generates
|
||||||
|
erroneous code (at least for targets using GOT) }
|
||||||
|
if global or
|
||||||
|
(cs_profile in current_settings.moduleswitches) then
|
||||||
|
result:=DefineAsmSymbol(s,AB_GLOBAL,AT_FUNCTION,pd)
|
||||||
|
else if tf_supports_hidden_symbols in target_info.flags then
|
||||||
|
result:=DefineAsmSymbol(s,AB_PRIVATE_EXTERN,AT_FUNCTION,pd)
|
||||||
|
else
|
||||||
|
result:=DefineAsmSymbol(s,AB_LOCAL,AT_FUNCTION,pd);
|
||||||
|
end;
|
||||||
|
|
||||||
function TAsmData.RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean) : TAsmSymbol;
|
function TAsmData.RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean) : TAsmSymbol;
|
||||||
var
|
var
|
||||||
namestr : TSymStr;
|
namestr : TSymStr;
|
||||||
|
@ -4590,14 +4590,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
item:=TCmdStrListItem(current_procinfo.procdef.aliasnames.first);
|
item:=TCmdStrListItem(current_procinfo.procdef.aliasnames.first);
|
||||||
firstitem:=item;
|
firstitem:=item;
|
||||||
global:=
|
global:=current_procinfo.procdef.needsglobalasmsym;
|
||||||
(cs_profile in current_settings.moduleswitches) or
|
|
||||||
{ smart linking using a library requires to promote
|
|
||||||
all non-nested procedures to AB_GLOBAL
|
|
||||||
otherwise you get undefined symbol error at linking
|
|
||||||
for msdos target with -CX option for instance }
|
|
||||||
(create_smartlink_library and not is_nested_pd(current_procinfo.procdef)) or
|
|
||||||
(po_global in current_procinfo.procdef.procoptions);
|
|
||||||
while assigned(item) do
|
while assigned(item) do
|
||||||
begin
|
begin
|
||||||
{$ifdef arm}
|
{$ifdef arm}
|
||||||
@ -4614,13 +4607,10 @@ implementation
|
|||||||
if global then
|
if global then
|
||||||
begin
|
begin
|
||||||
list.concat(tai_symbolpair.create(spk_set_global,item.str,firstitem.str));
|
list.concat(tai_symbolpair.create(spk_set_global,item.str,firstitem.str));
|
||||||
{ needed for generating the tai_symbol_end }
|
|
||||||
current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION,current_procinfo.procdef);
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
list.concat(tai_symbolpair.create(spk_set,item.str,firstitem.str));
|
list.concat(tai_symbolpair.create(spk_set,item.str,firstitem.str));
|
||||||
current_asmdata.DefineAsmSymbol(item.str,AB_PRIVATE_EXTERN,AT_FUNCTION,current_procinfo.procdef);
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -687,23 +687,13 @@ implementation
|
|||||||
|
|
||||||
procedure alloc_proc_symbol(pd: tprocdef);
|
procedure alloc_proc_symbol(pd: tprocdef);
|
||||||
var
|
var
|
||||||
item : TCmdStrListItem;
|
item: TCmdStrListItem;
|
||||||
begin
|
begin
|
||||||
item := TCmdStrListItem(pd.aliasnames.first);
|
item:=TCmdStrListItem(pd.aliasnames.first);
|
||||||
while assigned(item) do
|
while assigned(item) do
|
||||||
begin
|
begin
|
||||||
{ The condition to use global or local symbol must match
|
current_asmdata.DefineProcAsmSymbol(pd,item.str,pd.needsglobalasmsym);
|
||||||
the code written in hlcg.gen_proc_symbol to
|
item:=TCmdStrListItem(item.next);
|
||||||
avoid change from AB_LOCAL to AB_GLOBAL, which generates
|
|
||||||
erroneous code (at least for targets using GOT) }
|
|
||||||
if (cs_profile in current_settings.moduleswitches) or
|
|
||||||
(po_global in current_procinfo.procdef.procoptions) then
|
|
||||||
current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION,pd)
|
|
||||||
else if tf_supports_hidden_symbols in target_info.flags then
|
|
||||||
current_asmdata.DefineAsmSymbol(item.str,AB_PRIVATE_EXTERN,AT_FUNCTION,pd)
|
|
||||||
else
|
|
||||||
current_asmdata.DefineAsmSymbol(item.str,AB_LOCAL,AT_FUNCTION,pd);
|
|
||||||
item := TCmdStrListItem(item.next);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2583,15 +2583,7 @@ implementation
|
|||||||
|
|
||||||
{ make sure we don't change the binding of real external symbols }
|
{ make sure we don't change the binding of real external symbols }
|
||||||
if (([po_external,po_weakexternal]*pd.procoptions)=[]) and (pocall_internproc<>pd.proccalloption) then
|
if (([po_external,po_weakexternal]*pd.procoptions)=[]) and (pocall_internproc<>pd.proccalloption) then
|
||||||
begin
|
current_asmdata.DefineProcAsmSymbol(pd,pd.mangledname,pd.needsglobalasmsym);
|
||||||
if (po_global in pd.procoptions) or
|
|
||||||
(cs_profile in current_settings.moduleswitches) then
|
|
||||||
current_asmdata.DefineAsmSymbol(pd.mangledname,AB_GLOBAL,AT_FUNCTION,pd)
|
|
||||||
else if tf_supports_hidden_symbols in target_info.flags then
|
|
||||||
current_asmdata.DefineAsmSymbol(pd.mangledname,AB_PRIVATE_EXTERN,AT_FUNCTION,pd)
|
|
||||||
else
|
|
||||||
current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION,pd);
|
|
||||||
end;
|
|
||||||
|
|
||||||
current_structdef:=old_current_structdef;
|
current_structdef:=old_current_structdef;
|
||||||
current_genericdef:=old_current_genericdef;
|
current_genericdef:=old_current_genericdef;
|
||||||
|
@ -820,6 +820,7 @@ interface
|
|||||||
function GetTypeName : string;override;
|
function GetTypeName : string;override;
|
||||||
function mangledname : TSymStr; virtual;
|
function mangledname : TSymStr; virtual;
|
||||||
procedure setmangledname(const s : TSymStr);
|
procedure setmangledname(const s : TSymStr);
|
||||||
|
function needsglobalasmsym: boolean;
|
||||||
procedure setcompilerprocname;
|
procedure setcompilerprocname;
|
||||||
function fullprocname(showhidden:boolean):string;
|
function fullprocname(showhidden:boolean):string;
|
||||||
function customprocname(pno: tprocnameoptions):ansistring;
|
function customprocname(pno: tprocnameoptions):ansistring;
|
||||||
@ -1254,6 +1255,7 @@ implementation
|
|||||||
{ module }
|
{ module }
|
||||||
fmodule,
|
fmodule,
|
||||||
{ other }
|
{ other }
|
||||||
|
aasmbase,
|
||||||
gendef,
|
gendef,
|
||||||
fpccrc,
|
fpccrc,
|
||||||
entfile
|
entfile
|
||||||
@ -6556,6 +6558,18 @@ implementation
|
|||||||
include(procoptions,po_has_mangledname);
|
include(procoptions,po_has_mangledname);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function tprocdef.needsglobalasmsym: boolean;
|
||||||
|
begin
|
||||||
|
result:=
|
||||||
|
(cs_profile in current_settings.moduleswitches) or
|
||||||
|
{ smart linking using a library requires to promote
|
||||||
|
all non-nested procedures to AB_GLOBAL
|
||||||
|
otherwise you get undefined symbol error at linking
|
||||||
|
for msdos target with -CX option for instance }
|
||||||
|
(create_smartlink_library and not is_nested_pd(self)) or
|
||||||
|
(po_global in procoptions);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tprocdef.setcompilerprocname;
|
procedure tprocdef.setcompilerprocname;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user