mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 02:49:32 +01:00
* create stubs for library exports on Unix at at the node tree level instead
of using thlcg.g_external_wrapper() for high level targets, because that
way the creation of a new procdef for this stub and adding appropriate
entry/exit code can be handled using the standard compiler infrastructure
(fixes webtbs/tw8730* for LLVM)
git-svn-id: trunk@35088 -
This commit is contained in:
parent
d36fe53d85
commit
04f7e47df7
@ -58,11 +58,11 @@ uses
|
|||||||
globtype,globals,
|
globtype,globals,
|
||||||
aasmdata,aasmtai,aasmcpu,
|
aasmdata,aasmtai,aasmcpu,
|
||||||
fmodule,
|
fmodule,
|
||||||
|
{$ifdef cpuhighleveltarget}
|
||||||
|
symcreat,
|
||||||
|
{$endif}
|
||||||
cgbase,cgutils,cpubase,cgobj,
|
cgbase,cgutils,cpubase,cgobj,
|
||||||
cgcpu,hlcgobj,hlcgcpu,
|
cgcpu,hlcgobj,hlcgcpu,
|
||||||
{$ifdef llvm}
|
|
||||||
hlcgllvm,
|
|
||||||
{$endif llvm}
|
|
||||||
ncgutil,
|
ncgutil,
|
||||||
verbose;
|
verbose;
|
||||||
|
|
||||||
@ -89,6 +89,12 @@ end;
|
|||||||
procedure texportlibunix.exportprocedure(hp : texported_item);
|
procedure texportlibunix.exportprocedure(hp : texported_item);
|
||||||
var
|
var
|
||||||
hp2 : texported_item;
|
hp2 : texported_item;
|
||||||
|
{$ifdef cpuhighleveltarget}
|
||||||
|
pd,
|
||||||
|
wrapperpd: tprocdef;
|
||||||
|
i: longint;
|
||||||
|
anyhasalias: boolean;
|
||||||
|
{$endif cpuhighleveltarget}
|
||||||
begin
|
begin
|
||||||
{ first test the index value }
|
{ first test the index value }
|
||||||
if eo_index in hp.options then
|
if eo_index in hp.options then
|
||||||
@ -120,6 +126,36 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
current_module._exports.concat(hp);
|
current_module._exports.concat(hp);
|
||||||
|
{$ifdef cpuhighleveltarget}
|
||||||
|
{ in case of a high level target create a stub procedure at the node/def
|
||||||
|
level instead of via hlcg.g_external_wrapper() later on, because it's
|
||||||
|
hard to manually create a fake procedure there (and it requires a def
|
||||||
|
anyway) }
|
||||||
|
|
||||||
|
{ in case of eo_name there is no sym, and this routine is also called from
|
||||||
|
exportvar() so the sym doesn't have to be a procsym }
|
||||||
|
if assigned(hp.sym) and
|
||||||
|
(hp.sym.typ=procsym) then
|
||||||
|
begin
|
||||||
|
anyhasalias:=false;
|
||||||
|
{ if the procedure has the exported name as one of its aliases, we don't
|
||||||
|
need a separate stub }
|
||||||
|
for i:=0 to tprocsym(hp.sym).procdeflist.count-1 do
|
||||||
|
begin
|
||||||
|
pd:=tprocdef(tprocsym(hp.sym).procdeflist[i]);
|
||||||
|
anyhasalias:=pd.has_alias_name(hp.name^);
|
||||||
|
if anyhasalias then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if not anyhasalias then
|
||||||
|
begin
|
||||||
|
{ avoid name clashes for the identifier }
|
||||||
|
wrapperpd:=create_procdef_alias(pd,'$fpc_exported$'+hp.name^,hp.name^,
|
||||||
|
current_module.localsymtable,nil,
|
||||||
|
tsk_callthrough,pd);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$endif cpuhighleveltarget}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +183,7 @@ begin
|
|||||||
assigned(hp2.sym) and
|
assigned(hp2.sym) and
|
||||||
(hp2.sym.typ=procsym) then
|
(hp2.sym.typ=procsym) then
|
||||||
begin
|
begin
|
||||||
|
{$ifndef cpuhighleveltarget}
|
||||||
{ the manglednames can already be the same when the procedure
|
{ the manglednames can already be the same when the procedure
|
||||||
is declared with cdecl }
|
is declared with cdecl }
|
||||||
{ note: for "exports" sections we only allow non overloaded procsyms,
|
{ note: for "exports" sections we only allow non overloaded procsyms,
|
||||||
@ -161,6 +198,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
if not anyhasalias then
|
if not anyhasalias then
|
||||||
hlcg.g_external_wrapper(current_asmdata.asmlists[al_procedures],pd,hp2.name^,pd.mangledname,true);
|
hlcg.g_external_wrapper(current_asmdata.asmlists[al_procedures],pd,hp2.name^,pd.mangledname,true);
|
||||||
|
{$endif cpuhighleveltarget}
|
||||||
exportedsymnames.insert(hp2.name^);
|
exportedsymnames.insert(hp2.name^);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user