|
@@ -58,11 +58,11 @@ uses
|
|
|
globtype,globals,
|
|
|
aasmdata,aasmtai,aasmcpu,
|
|
|
fmodule,
|
|
|
+ {$ifdef cpuhighleveltarget}
|
|
|
+ symcreat,
|
|
|
+ {$endif}
|
|
|
cgbase,cgutils,cpubase,cgobj,
|
|
|
cgcpu,hlcgobj,hlcgcpu,
|
|
|
-{$ifdef llvm}
|
|
|
- hlcgllvm,
|
|
|
-{$endif llvm}
|
|
|
ncgutil,
|
|
|
verbose;
|
|
|
|
|
@@ -89,6 +89,12 @@ end;
|
|
|
procedure texportlibunix.exportprocedure(hp : texported_item);
|
|
|
var
|
|
|
hp2 : texported_item;
|
|
|
+{$ifdef cpuhighleveltarget}
|
|
|
+ pd,
|
|
|
+ wrapperpd: tprocdef;
|
|
|
+ i: longint;
|
|
|
+ anyhasalias: boolean;
|
|
|
+{$endif cpuhighleveltarget}
|
|
|
begin
|
|
|
{ first test the index value }
|
|
|
if eo_index in hp.options then
|
|
@@ -120,6 +126,36 @@ begin
|
|
|
end
|
|
|
else
|
|
|
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;
|
|
|
|
|
|
|
|
@@ -147,6 +183,7 @@ begin
|
|
|
assigned(hp2.sym) and
|
|
|
(hp2.sym.typ=procsym) then
|
|
|
begin
|
|
|
+{$ifndef cpuhighleveltarget}
|
|
|
{ the manglednames can already be the same when the procedure
|
|
|
is declared with cdecl }
|
|
|
{ note: for "exports" sections we only allow non overloaded procsyms,
|
|
@@ -161,6 +198,7 @@ begin
|
|
|
end;
|
|
|
if not anyhasalias then
|
|
|
hlcg.g_external_wrapper(current_asmdata.asmlists[al_procedures],pd,hp2.name^,pd.mangledname,true);
|
|
|
+{$endif cpuhighleveltarget}
|
|
|
exportedsymnames.insert(hp2.name^);
|
|
|
end
|
|
|
else
|