From 2435a7a93c7be5c2cb2906b4b3b460bc84bf5716 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 7 Feb 2006 14:29:58 +0000 Subject: [PATCH] * finalization sections in shared libraries under Darwin are now run * cleaned up the way the initialisation sections of shared libraries under Darwin are run git-svn-id: trunk@2470 - --- compiler/aasmtai.pas | 6 +++--- compiler/ncgutil.pas | 15 +++++++++++++++ compiler/pmodules.pas | 3 ++- compiler/systems/t_bsd.pas | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index 98ea5b9141..52541055d5 100644 --- a/compiler/aasmtai.pas +++ b/compiler/aasmtai.pas @@ -306,7 +306,7 @@ interface end; tasmdirective=(asd_non_lazy_symbol_pointer,asd_indirect_symbol,asd_lazy_symbol_pointer, - asd_extern,asd_nasm_import, asd_toc_entry); + asd_extern,asd_nasm_import, asd_toc_entry, asd_mod_init_func, asd_mod_term_func); tai_directive = class(tailineinfo) name : pstring; @@ -664,9 +664,9 @@ interface regallocstr : array[tregalloctype] of string[10]=('allocated','released','sync','resized'); tempallocstr : array[boolean] of string[10]=('released','allocated'); stabtypestr : array[tstabtype] of string[5]=('stabs','stabn','stabd'); - directivestr : array[tasmdirective] of string[24]=( + directivestr : array[tasmdirective] of string[23]=( 'non_lazy_symbol_pointer','indirect_symbol','lazy_symbol_pointer', - 'extern','nasm_import', 'tc' + 'extern','nasm_import', 'tc', 'mod_init_func', 'mod_term_func' ); var diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index cce723e22c..ea0fd3e716 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -1787,6 +1787,21 @@ implementation list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname)); current_procinfo.procdef.procendtai:=tai(list.last); + + { finalisation marker for Mac OS X } + if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) and + (current_module.islibrary) and + (((current_module.flags and uf_finalize)<>0) or + (current_procinfo.procdef.proctypeoption = potype_proginit)) then + begin + if (current_procinfo.procdef.proctypeoption = potype_proginit) then + list.concat(tai_directive.create(asd_mod_init_func,'')) + else + list.concat(tai_directive.create(asd_mod_term_func,'')); + list.concat(tai_align.create(4)); + list.concat(Tai_const.Createname(current_procinfo.procdef.mangledname,AT_FUNCTION,0)); + end; + end; diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index a701254031..aca6bb0007 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -1287,7 +1287,8 @@ implementation begin pd:=create_main_proc(make_mangledname('',current_module.localsymtable,mainaliasname),potype_proginit,current_module.localsymtable); { Win32 startup code needs a single name } - pd.aliasnames.insert('PASCALMAIN'); + if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then + pd.aliasnames.insert('PASCALMAIN'); end else if (target_info.system = system_i386_netware) or (target_info.system = system_i386_netwlibc) then diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas index b70fcf47e0..6f4c4f23a9 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -287,7 +287,7 @@ begin else begin ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`'; - DllCmd[1]:='libtool $OPT -dynamic -init PASCALMAIN -multiply_defined suppress -L. -o $EXE `cat $RES`' + DllCmd[1]:='libtool $OPT -dynamic -multiply_defined suppress -L. -o $EXE `cat $RES`' end end else