* moved the code generated for library init/fini to the al_pure_assembler

list, so that the assembler directives generated for Darwin are emitted
    correctly for LLVM
   o extracted the library init code generation from hlcgobj to pmodules so
     we don't add things to another list than what's passed to
     gen_proc_symbol_end(), and so it's done where we generate the init
     routine for libraries (rather then checking for every routine whether
     it's the init routine for a library)
   o removed the llvm-specific gen_proc_symbol_end() because the regular one
     now does the same

git-svn-id: trunk@34134 -
This commit is contained in:
Jonas Maebe 2016-07-15 14:34:11 +00:00
parent a0bc21b072
commit 88a736c95a
3 changed files with 17 additions and 27 deletions

View File

@ -4479,26 +4479,9 @@ implementation
end;
procedure thlcgobj.gen_proc_symbol_end(list: TAsmList);
var
initname : tsymstr;
begin
list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
current_procinfo.procdef.procendtai:=tai(list.last);
if (current_module.islibrary) then
if (current_procinfo.procdef.proctypeoption = potype_proginit) then
begin
{ ToDo: systems that use indirect entry info, but check back with Windows! }
if target_info.system in systems_darwin then
{ we need to call FPC_LIBMAIN in sysinit which in turn will call PascalMain }
initname:=target_info.cprefix+'FPC_LIBMAIN'
else
initname:=current_procinfo.procdef.mangledname;
{ setinitname may generate a new section -> don't add to the
current list, because we assume this remains a text section }
exportlib.setinitname(current_asmdata.AsmLists[al_exports],initname);
end;
end;

View File

@ -96,7 +96,6 @@ uses
procedure a_loadfpu_reg_reg(list: TAsmList; fromsize, tosize: tdef; reg1, reg2: tregister); override;
procedure gen_proc_symbol(list: TAsmList); override;
procedure gen_proc_symbol_end(list: TAsmList); override;
procedure handle_external_proc(list: TAsmList; pd: tprocdef; const importname: TSymStr); override;
procedure g_proc_entry(list : TAsmList;localsize : longint;nostackframe:boolean); override;
procedure g_proc_exit(list : TAsmList;parasize:longint;nostackframe:boolean); override;
@ -1247,13 +1246,6 @@ implementation
end;
procedure thlcgllvm.gen_proc_symbol_end(list: TAsmList);
begin
list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
{ todo: darwin main proc, or handle in other way? }
end;
procedure thlcgllvm.handle_external_proc(list: TAsmList; pd: tprocdef; const importname: TSymStr);
begin
{ don't do anything, because at this point we can't know yet for certain

View File

@ -1808,6 +1808,7 @@ type
main_procinfo : tcgprocinfo;
force_init_final : boolean;
resources_used : boolean;
initname,
program_name : ansistring;
consume_semicolon_after_uses : boolean;
ps : tprogramparasym;
@ -2023,7 +2024,19 @@ type
if not(target_info.system in (systems_darwin+systems_aix)) then
main_procinfo.procdef.aliasnames.insert('PASCALMAIN')
else
main_procinfo.procdef.aliasnames.insert(target_info.Cprefix+'PASCALMAIN')
main_procinfo.procdef.aliasnames.insert(target_info.Cprefix+'PASCALMAIN');
{ ToDo: systems that use indirect entry info, but check back with Windows! }
if target_info.system in systems_darwin then
{ we need to call FPC_LIBMAIN in sysinit which in turn will call PascalMain }
initname:=target_info.cprefix+'FPC_LIBMAIN'
else
initname:=current_procinfo.procdef.mangledname;
{ setinitname may generate a new section -> don't add to the
current list, because we assume this remains a text section
-- add to pure assembler section, so in case of special directives
they are directly added to the assembler output by llvm }
exportlib.setinitname(current_asmdata.AsmLists[al_pure_assembler],initname);
end
else if (target_info.system in ([system_i386_netware,system_i386_netwlibc,system_powerpc_macos]+systems_darwin+systems_aix)) then
begin
@ -2087,8 +2100,10 @@ type
{ the finalization routine of libraries is generic (and all libraries need to }
{ be finalized, so they can finalize any units they use }
{ Place in "pure assembler" list so that the llvm assembler writer
directly emits the generated directives }
if (islibrary) then
exportlib.setfininame(current_asmdata.asmlists[al_procedures],'FPC_LIB_EXIT');
exportlib.setfininame(current_asmdata.asmlists[al_pure_assembler],'FPC_LIB_EXIT');
{ all labels must be defined before generating code }
if Errorcount=0 then