From cab0690455fef9ce88aa0d3659f7ce3bbad6d53b Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 15 Dec 2009 19:44:33 +0000 Subject: [PATCH] 2009-12-15 20:43 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbinit.h * eliminated from ASM code used in HB_INITSEG_STARTUP direct references to public functions - it resolves the problem with non relocatable code breaking Harbour shared library. TODO: find portable method to mark function as used for C compiler without using any public symbols (functions or variables) which may cause conflicts between modules. Compilers like modern GCC versions are clever enough to detect cyclic references (only compile time warnings are pacified in such case) and they strip even group of functions it they are not accessed externally. --- harbour/ChangeLog | 13 +++++++++++++ harbour/include/hbinit.h | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index dd0254dedc..96174a2046 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,19 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-15 20:43 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbinit.h + * eliminated from ASM code used in HB_INITSEG_STARTUP direct references + to public functions - it resolves the problem with non relocatable + code breaking Harbour shared library. + TODO: find portable method to mark function as used for C compiler + without using any public symbols (functions or variables) + which may cause conflicts between modules. + Compilers like modern GCC versions are clever enough to detect + cyclic references (only compile time warnings are pacified in + such case) and they strip even group of functions it they are + not accessed externally. + 2009-12-15 19:47 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbinit.h + added new alternative form for initialization code activated diff --git a/harbour/include/hbinit.h b/harbour/include/hbinit.h index e41c45884c..c62a9748ef 100644 --- a/harbour/include/hbinit.h +++ b/harbour/include/hbinit.h @@ -120,20 +120,27 @@ extern HB_EXPORT PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbo #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \ }; \ static PHB_SYMB symbols = symbols_table; \ - void func( void ) \ - { \ + HB_CALL_ON_STARTUP_BEGIN( func ) \ symbols = hb_vmProcessSymbols( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \ - } \ - __asm__ ( ".section .init\n\tcall " HB_MACRO2STRING( func ) "\n\t" ); + HB_CALL_ON_STARTUP_END( func ) #define HB_CALL_ON_STARTUP_BEGIN( func ) \ - void func( void ) \ + static void func( void ) \ { #define HB_CALL_ON_STARTUP_END( func ) \ } \ + HB_INIT_FUNCTION_REF( func ) \ __asm__ ( ".section .init\n\tcall " HB_MACRO2STRING( func ) "\n\t" ); + + #define HB_INIT_FUNCTION_REF( func ) \ + extern void * func##_ref_( void ); \ + void * func##_ref_( void ) \ + { \ + return ( void * ) func; \ + } + #elif defined( __GNUC__ ) || defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) #if defined( HB_PRAGMA_STARTUP ) || defined( HB_MSC_STARTUP )