From 9772a398af7daef47279de53d75603c219d56b02 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Sun, 26 Dec 2021 11:35:16 -0300 Subject: [PATCH] Fix MacOS UDR and Legacy_UserManager plugins not working due to not exported entry point. (#7088) Add FB_DLL_EXPORT to public headers. Use default visibility also for Linux/Unix (in addition to MacOS) as user application can also be compiled with -fvisibility=hidden. --- doc/Using_OO_API.html | 4 ++-- examples/dbcrypt/CryptKeyHolder.cpp | 2 +- examples/dbcrypt/DbCrypt.cpp | 2 +- examples/extauth/ExtAuth.cpp | 8 +------- examples/interfaces/ifaceExamples.h | 8 -------- examples/replication/fbSampleReplicator.cpp | 9 +-------- src/auth/AuthDbg.cpp | 2 +- .../SecureRemotePassword/manage/SrpManagement.cpp | 10 +--------- src/auth/SecurityDatabase/LegacyManagement.epp | 2 +- src/auth/SecurityDatabase/LegacyServer.cpp | 2 +- src/common/common.h | 6 ------ src/extlib/ib_util.cpp | 8 +++----- src/include/firebird.h | 7 ------- src/include/firebird/UdrCppEngine.h | 2 +- src/include/ibase.h | 12 ++++++++++++ src/intl/ld.cpp | 8 ++++---- src/intl/ld.h | 8 -------- src/intl/ld_proto.h | 8 ++++---- src/jrd/jrd.cpp | 2 +- src/plugins/crypt/chacha/ChaCha.cpp | 2 +- src/plugins/udr_engine/UdrEngine.cpp | 2 +- src/remote/client/interface.cpp | 2 +- src/utilities/ntrace/traceplugin.cpp | 2 +- src/yvalve/gds.cpp | 4 ++-- src/yvalve/gds_proto.h | 6 ++++-- 25 files changed, 45 insertions(+), 83 deletions(-) diff --git a/doc/Using_OO_API.html b/doc/Using_OO_API.html index b15ab1adf4..841a4b49d4 100644 --- a/doc/Using_OO_API.html +++ b/doc/Using_OO_API.html @@ -1673,7 +1673,7 @@ only for some specific OS you can make this place a bit simpler. In minimum case the function should register module and all factories in plugin manager:

extern -"C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* +"C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)

{

IPluginManager* @@ -3793,4 +3793,4 @@ release of it.

- \ No newline at end of file + diff --git a/examples/dbcrypt/CryptKeyHolder.cpp b/examples/dbcrypt/CryptKeyHolder.cpp index bc79942238..efa57df60f 100644 --- a/examples/dbcrypt/CryptKeyHolder.cpp +++ b/examples/dbcrypt/CryptKeyHolder.cpp @@ -298,7 +298,7 @@ Factory factory; } // anonymous namespace -extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* m) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m) { master = m; IPluginManager* pluginManager = master->getPluginManager(); diff --git a/examples/dbcrypt/DbCrypt.cpp b/examples/dbcrypt/DbCrypt.cpp index fcfc1ba3f4..6b0260eb27 100644 --- a/examples/dbcrypt/DbCrypt.cpp +++ b/examples/dbcrypt/DbCrypt.cpp @@ -266,7 +266,7 @@ Factory factory; } // anonymous namespace -extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { IPluginManager* pluginManager = master->getPluginManager(); diff --git a/examples/extauth/ExtAuth.cpp b/examples/extauth/ExtAuth.cpp index 5c3c5efd4d..56926575f6 100644 --- a/examples/extauth/ExtAuth.cpp +++ b/examples/extauth/ExtAuth.cpp @@ -435,13 +435,7 @@ Factory serverFactory; } // anonymous namespace -#if defined(_WIN32) -#define FB_DLL_EXPORT __declspec(dllexport) -#else -#define FB_DLL_EXPORT -#endif - -extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* m) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m) { master = m; IPluginManager* pluginManager = master->getPluginManager(); diff --git a/examples/interfaces/ifaceExamples.h b/examples/interfaces/ifaceExamples.h index da349264dc..cfcb1f9dca 100644 --- a/examples/interfaces/ifaceExamples.h +++ b/examples/interfaces/ifaceExamples.h @@ -37,14 +37,6 @@ typedef int FbSampleAtomic; #include -#if defined(_WIN32) -#define FB_DLL_EXPORT __declspec(dllexport) -#elif defined(__APPLE__) -#define FB_DLL_EXPORT __attribute__((visibility("default"))) -#else -#define FB_DLL_EXPORT -#endif - using namespace Firebird; #define SAMPLES_DIALECT SQL_DIALECT_V6 diff --git a/examples/replication/fbSampleReplicator.cpp b/examples/replication/fbSampleReplicator.cpp index fa8f63232b..fcf59537b2 100644 --- a/examples/replication/fbSampleReplicator.cpp +++ b/examples/replication/fbSampleReplicator.cpp @@ -100,14 +100,7 @@ public: extern "C" { -#if defined(__WIN32__) - void __declspec(dllexport) FB_PLUGIN_ENTRY_POINT(IMaster* m); -#else - void FB_PLUGIN_ENTRY_POINT(IMaster* m) - __attribute__((visibility("default"))); -#endif // __WIN32__ - - void FB_PLUGIN_ENTRY_POINT(IMaster* m) + FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m) { master = m; IPluginManager* pm = m->getPluginManager(); diff --git a/src/auth/AuthDbg.cpp b/src/auth/AuthDbg.cpp index 6f2110e629..386f9f5e23 100644 --- a/src/auth/AuthDbg.cpp +++ b/src/auth/AuthDbg.cpp @@ -38,7 +38,7 @@ static Firebird::SimpleFactory clientFactory; static Firebird::SimpleFactory serverFactory; -extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { Firebird::CachedMasterInterface::set(master); diff --git a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp index b2150ac155..ce17331521 100644 --- a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp +++ b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp @@ -38,14 +38,6 @@ #include "../common/classes/auto.h" #include "../common/classes/ParsedList.h" -#ifndef FB_EXPORTED -#if defined(DARWIN) -#define FB_EXPORTED __attribute__((visibility("default"))) -#else -#define FB_EXPORTED -#endif // OS choice (DARWIN) -#endif // FB_EXPORTED - namespace { const unsigned int SZ_LOGIN = 31; @@ -986,7 +978,7 @@ static Firebird::SimpleFactory factory; } // namespace Auth -extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { Firebird::CachedMasterInterface::set(master); Firebird::PluginManagerInterfacePtr()->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, Auth::RemotePassword::plugName, &Auth::factory); diff --git a/src/auth/SecurityDatabase/LegacyManagement.epp b/src/auth/SecurityDatabase/LegacyManagement.epp index b60aeed564..80cbc070dc 100644 --- a/src/auth/SecurityDatabase/LegacyManagement.epp +++ b/src/auth/SecurityDatabase/LegacyManagement.epp @@ -762,7 +762,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi // register plugin static Firebird::SimpleFactory factory; -extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { Firebird::CachedMasterInterface::set(master); Firebird::PluginManagerInterfacePtr()->registerPluginFactory( diff --git a/src/auth/SecurityDatabase/LegacyServer.cpp b/src/auth/SecurityDatabase/LegacyServer.cpp index 23f9b471c2..0c7e59a855 100644 --- a/src/auth/SecurityDatabase/LegacyServer.cpp +++ b/src/auth/SecurityDatabase/LegacyServer.cpp @@ -411,7 +411,7 @@ void registerLegacyServer(IPluginManager* iPlugin) #ifdef PLUG_MODULE -extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { CachedMasterInterface::set(master); diff --git a/src/common/common.h b/src/common/common.h index c5d3079fc1..c73511cfa1 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -252,8 +252,6 @@ #define API_ROUTINE __attribute__((visibility("default"))) #define API_ROUTINE_VARARG API_ROUTINE -#define INTERNAL_API_ROUTINE API_ROUTINE -#define FB_EXPORTED __attribute__((visibility("default"))) #define O_DIRECT F_NOCACHE #endif /* Darwin Platforms */ @@ -603,10 +601,6 @@ extern "C" int remove(const char* path); #define CLIB_ROUTINE #endif -#ifndef FB_EXPORTED -#define FB_EXPORTED -#endif - #ifdef HAS_NOEXCEPT #define NOEXCEPT noexcept #define NOEXCEPT_ARG(X) noexcept((X)) diff --git a/src/extlib/ib_util.cpp b/src/extlib/ib_util.cpp index 114825ae85..614fc96d2d 100644 --- a/src/extlib/ib_util.cpp +++ b/src/extlib/ib_util.cpp @@ -19,21 +19,19 @@ */ #include -#include "ib_util.h" #include "firebird.h" - -typedef void* VoidPtr; +#include "ibase.h" // initialized by the engine static void* (*allocFunc)(long) = NULL; -extern "C" void FB_EXPORTED ib_util_init(void* (*aAllocFunc)(long)) +extern "C" FB_DLL_EXPORT void ib_util_init(void* (*aAllocFunc)(long)) { allocFunc = aAllocFunc; } -extern "C" VoidPtr FB_EXPORTED ib_util_malloc(long size) +extern "C" FB_DLL_EXPORT void* ib_util_malloc(long size) { return allocFunc ? allocFunc(size) : malloc(size); } diff --git a/src/include/firebird.h b/src/include/firebird.h index 1bd7f2d4b3..391d7707ce 100644 --- a/src/include/firebird.h +++ b/src/include/firebird.h @@ -43,13 +43,6 @@ #define DEBUG_GDS_ALLOC #endif -#if defined(WIN_NT) -#define FB_DLL_EXPORT __declspec(dllexport) -#elif defined(DARWIN) -#define FB_DLL_EXPORT API_ROUTINE -#else -#define FB_DLL_EXPORT -#endif //#if defined(SOLX86) // this pragmas is used only with gcc 2.95! //#define __PRAGMA_REDEFINE_EXTNAME diff --git a/src/include/firebird/UdrCppEngine.h b/src/include/firebird/UdrCppEngine.h index 26ef5a0e90..d9aac7e5d3 100644 --- a/src/include/firebird/UdrCppEngine.h +++ b/src/include/firebird/UdrCppEngine.h @@ -43,7 +43,7 @@ } \ } \ \ - extern "C" FB_BOOLEAN* FB_UDR_PLUGIN_ENTRY_POINT(::Firebird::IStatus* status, \ + extern "C" FB_DLL_EXPORT FB_BOOLEAN* FB_UDR_PLUGIN_ENTRY_POINT(::Firebird::IStatus* status, \ FB_BOOLEAN* theirUnloadFlag, ::Firebird::IUdrPlugin* udrPlugin) \ { \ ::Firebird::Udr::FactoryRegistration::finish(status, udrPlugin); \ diff --git a/src/include/ibase.h b/src/include/ibase.h index 6f7e593b2c..957afbb2d3 100644 --- a/src/include/ibase.h +++ b/src/include/ibase.h @@ -64,6 +64,18 @@ #define FB_API_DEPRECATED #endif +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +#define FB_DLL_EXPORT __declspec(dllexport) +#elif defined __has_attribute +#if __has_attribute (visibility) +#define FB_DLL_EXPORT __attribute__ ((visibility("default"))) +#else +#define FB_DLL_EXPORT +#endif +#else +#define FB_DLL_EXPORT +#endif + #include "./firebird/impl/types_pub.h" /***********************/ diff --git a/src/intl/ld.cpp b/src/intl/ld.cpp index 1056921ee3..151cd3e812 100644 --- a/src/intl/ld.cpp +++ b/src/intl/ld.cpp @@ -468,7 +468,7 @@ struct }; -INTL_BOOL FB_DLL_EXPORT LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* /*config_info*/) +FB_DLL_EXPORT INTL_BOOL LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* /*config_info*/) { // ASF: We can't read config_info if version < INTL_VERSION_2, // since it wasn't pushed in the stack by the engine. @@ -491,7 +491,7 @@ INTL_BOOL FB_DLL_EXPORT LD_lookup_charset(charset* cs, const ASCII* name, const } -INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name, +FB_DLL_EXPORT INTL_BOOL LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name, USHORT attributes, const UCHAR* specific_attributes, ULONG specific_attributes_length, INTL_BOOL ignore_attributes, const ASCII* config_info) @@ -557,7 +557,7 @@ INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_n } -ULONG FB_DLL_EXPORT LD_setup_attributes( +FB_DLL_EXPORT ULONG LD_setup_attributes( const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst) { @@ -583,7 +583,7 @@ ULONG FB_DLL_EXPORT LD_setup_attributes( } -void FB_DLL_EXPORT LD_version(USHORT* version) +FB_DLL_EXPORT void LD_version(USHORT* version) { // We support version 1 and 2. if (*version != INTL_VERSION_1) diff --git a/src/intl/ld.h b/src/intl/ld.h index 0ee001f733..0fc0237bad 100644 --- a/src/intl/ld.h +++ b/src/intl/ld.h @@ -55,14 +55,6 @@ #define UINT16 USHORT -#if defined(WIN_NT) -#define FB_DLL_EXPORT __declspec(dllexport) -#elif defined(DARWIN) -#define FB_DLL_EXPORT API_ROUTINE -#else -#define FB_DLL_EXPORT -#endif - /* Following this line is LD.H from Borland Language Driver Kit */ diff --git a/src/intl/ld_proto.h b/src/intl/ld_proto.h index 6a6636dfa1..f20fdf076a 100644 --- a/src/intl/ld_proto.h +++ b/src/intl/ld_proto.h @@ -38,13 +38,13 @@ struct CsConvertImpl extern USHORT version; -INTL_BOOL FB_DLL_EXPORT LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* config_info); -INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name, +FB_DLL_EXPORT INTL_BOOL LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* config_info); +FB_DLL_EXPORT INTL_BOOL LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name, USHORT attributes, const UCHAR* specific_attributes, ULONG specific_attributes_length, INTL_BOOL ignore_attributes, const ASCII* config_info); -void FB_DLL_EXPORT LD_version(USHORT* version); -ULONG FB_DLL_EXPORT LD_setup_attributes( +FB_DLL_EXPORT void LD_version(USHORT* version); +FB_DLL_EXPORT ULONG LD_setup_attributes( const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst); diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index dab848ce40..c6539a42bc 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -465,7 +465,7 @@ void registerEngine(IPluginManager* iPlugin) } // namespace Jrd -extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { CachedMasterInterface::set(master); registerEngine(PluginManagerInterfacePtr()); diff --git a/src/plugins/crypt/chacha/ChaCha.cpp b/src/plugins/crypt/chacha/ChaCha.cpp index 33d9c0d4ec..2748a82191 100644 --- a/src/plugins/crypt/chacha/ChaCha.cpp +++ b/src/plugins/crypt/chacha/ChaCha.cpp @@ -189,7 +189,7 @@ SimpleFactory > factory64; } // anonymous namespace -extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { CachedMasterInterface::set(master); PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_WIRE_CRYPT, "ChaCha", &factory); diff --git a/src/plugins/udr_engine/UdrEngine.cpp b/src/plugins/udr_engine/UdrEngine.cpp index 25a35cb5e0..e6549c35f2 100644 --- a/src/plugins/udr_engine/UdrEngine.cpp +++ b/src/plugins/udr_engine/UdrEngine.cpp @@ -718,7 +718,7 @@ class IExternalEngineFactoryImpl : public SimpleFactory { } factory; -extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { CachedMasterInterface::set(master); diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp index 1343aeadc4..6567b98f9c 100644 --- a/src/remote/client/interface.cpp +++ b/src/remote/client/interface.cpp @@ -1046,7 +1046,7 @@ void registerRedirector(Firebird::IPluginManager* iPlugin) } // namespace Remote /* -extern "C" void FB_PLUGIN_ENTRY_POINT(IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { IPluginManager* pi = master->getPluginManager(); registerRedirector(pi); diff --git a/src/utilities/ntrace/traceplugin.cpp b/src/utilities/ntrace/traceplugin.cpp index 39cde97145..6fe0c013b4 100644 --- a/src/utilities/ntrace/traceplugin.cpp +++ b/src/utilities/ntrace/traceplugin.cpp @@ -115,7 +115,7 @@ void registerTrace(Firebird::IPluginManager* iPlugin) } -extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { Firebird::CachedMasterInterface::set(master); registerTrace(Firebird::PluginManagerInterfacePtr()); diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index 387b46c2d7..618ddeccb7 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -3977,13 +3977,13 @@ static void sanitize(Firebird::string& locale) } -void FB_EXPORTED gds__default_printer(void* /*arg*/, SSHORT offset, const TEXT* line) +void API_ROUTINE_VARARG gds__default_printer(void* /*arg*/, SSHORT offset, const TEXT* line) { printf("%4d %s\n", offset, line); } -void FB_EXPORTED gds__trace_printer(void* /*arg*/, SSHORT offset, const TEXT* line) +void API_ROUTINE_VARARG gds__trace_printer(void* /*arg*/, SSHORT offset, const TEXT* line) { // Assume that line is not too long char buffer[PRETTY_BUFFER_SIZE + 10]; diff --git a/src/yvalve/gds_proto.h b/src/yvalve/gds_proto.h index 384cce4be1..8f1e91fe04 100644 --- a/src/yvalve/gds_proto.h +++ b/src/yvalve/gds_proto.h @@ -134,8 +134,10 @@ SINT64 API_ROUTINE isc_portable_integer(const UCHAR*, SSHORT); void gds__cleanup(); void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler); -void FB_EXPORTED gds__default_printer(void*, SSHORT, const TEXT*); -void FB_EXPORTED gds__trace_printer(void*, SSHORT, const TEXT*); +// These functions uses cdecl convention in Windows, so use API_ROUTINE_VARARG instead of API_ROUTINE (stdcall). +void API_ROUTINE_VARARG gds__default_printer(void*, SSHORT, const TEXT*); +void API_ROUTINE_VARARG gds__trace_printer(void*, SSHORT, const TEXT*); + #ifdef NOT_USED_OR_REPLACED void gds__print_pool(Firebird::MemoryPool*, const TEXT*, ...); #endif