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 )