8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:03:03 +01:00

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.
This commit is contained in:
Adriano dos Santos Fernandes 2021-12-26 11:35:16 -03:00 committed by GitHub
parent a0c88b8303
commit 9772a398af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 45 additions and 83 deletions

View File

@ -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 minimum case the function should register module and all factories in
plugin manager:</font></p> plugin manager:</font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">extern <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">extern
&quot;C&quot; void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* &quot;C&quot; FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster*
master)</font></p> master)</font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">{</font></p> <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">{</font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">IPluginManager* <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">IPluginManager*
@ -3793,4 +3793,4 @@ release of it.</font></p>
</p> </p>
</body> </body>
</html> </html>

View File

@ -298,7 +298,7 @@ Factory factory;
} // anonymous namespace } // 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; master = m;
IPluginManager* pluginManager = master->getPluginManager(); IPluginManager* pluginManager = master->getPluginManager();

View File

@ -266,7 +266,7 @@ Factory factory;
} // anonymous namespace } // 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(); IPluginManager* pluginManager = master->getPluginManager();

View File

@ -435,13 +435,7 @@ Factory<ExtAuthServer> serverFactory;
} // anonymous namespace } // anonymous namespace
#if defined(_WIN32) extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m)
#define FB_DLL_EXPORT __declspec(dllexport)
#else
#define FB_DLL_EXPORT
#endif
extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* m)
{ {
master = m; master = m;
IPluginManager* pluginManager = master->getPluginManager(); IPluginManager* pluginManager = master->getPluginManager();

View File

@ -37,14 +37,6 @@ typedef int FbSampleAtomic;
#include <firebird/Interface.h> #include <firebird/Interface.h>
#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; using namespace Firebird;
#define SAMPLES_DIALECT SQL_DIALECT_V6 #define SAMPLES_DIALECT SQL_DIALECT_V6

View File

@ -100,14 +100,7 @@ public:
extern "C" extern "C"
{ {
#if defined(__WIN32__) FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m)
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)
{ {
master = m; master = m;
IPluginManager* pm = m->getPluginManager(); IPluginManager* pm = m->getPluginManager();

View File

@ -38,7 +38,7 @@
static Firebird::SimpleFactory<Auth::DebugClient> clientFactory; static Firebird::SimpleFactory<Auth::DebugClient> clientFactory;
static Firebird::SimpleFactory<Auth::DebugServer> serverFactory; static Firebird::SimpleFactory<Auth::DebugServer> 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); Firebird::CachedMasterInterface::set(master);

View File

@ -38,14 +38,6 @@
#include "../common/classes/auto.h" #include "../common/classes/auto.h"
#include "../common/classes/ParsedList.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 { namespace {
const unsigned int SZ_LOGIN = 31; const unsigned int SZ_LOGIN = 31;
@ -986,7 +978,7 @@ static Firebird::SimpleFactory<Auth::SrpManagement> factory;
} // namespace Auth } // 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::CachedMasterInterface::set(master);
Firebird::PluginManagerInterfacePtr()->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, Auth::RemotePassword::plugName, &Auth::factory); Firebird::PluginManagerInterfacePtr()->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, Auth::RemotePassword::plugName, &Auth::factory);

View File

@ -762,7 +762,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi
// register plugin // register plugin
static Firebird::SimpleFactory<Auth::SecurityDatabaseManagement> factory; static Firebird::SimpleFactory<Auth::SecurityDatabaseManagement> 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::CachedMasterInterface::set(master);
Firebird::PluginManagerInterfacePtr()->registerPluginFactory( Firebird::PluginManagerInterfacePtr()->registerPluginFactory(

View File

@ -411,7 +411,7 @@ void registerLegacyServer(IPluginManager* iPlugin)
#ifdef PLUG_MODULE #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); CachedMasterInterface::set(master);

View File

@ -252,8 +252,6 @@
#define API_ROUTINE __attribute__((visibility("default"))) #define API_ROUTINE __attribute__((visibility("default")))
#define API_ROUTINE_VARARG API_ROUTINE #define API_ROUTINE_VARARG API_ROUTINE
#define INTERNAL_API_ROUTINE API_ROUTINE
#define FB_EXPORTED __attribute__((visibility("default")))
#define O_DIRECT F_NOCACHE #define O_DIRECT F_NOCACHE
#endif /* Darwin Platforms */ #endif /* Darwin Platforms */
@ -603,10 +601,6 @@ extern "C" int remove(const char* path);
#define CLIB_ROUTINE #define CLIB_ROUTINE
#endif #endif
#ifndef FB_EXPORTED
#define FB_EXPORTED
#endif
#ifdef HAS_NOEXCEPT #ifdef HAS_NOEXCEPT
#define NOEXCEPT noexcept #define NOEXCEPT noexcept
#define NOEXCEPT_ARG(X) noexcept((X)) #define NOEXCEPT_ARG(X) noexcept((X))

View File

@ -19,21 +19,19 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "ib_util.h"
#include "firebird.h" #include "firebird.h"
#include "ibase.h"
typedef void* VoidPtr;
// initialized by the engine // initialized by the engine
static void* (*allocFunc)(long) = NULL; 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; 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); return allocFunc ? allocFunc(size) : malloc(size);
} }

View File

@ -43,13 +43,6 @@
#define DEBUG_GDS_ALLOC #define DEBUG_GDS_ALLOC
#endif #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) //#if defined(SOLX86)
// this pragmas is used only with gcc 2.95! // this pragmas is used only with gcc 2.95!
//#define __PRAGMA_REDEFINE_EXTNAME //#define __PRAGMA_REDEFINE_EXTNAME

View File

@ -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) \ FB_BOOLEAN* theirUnloadFlag, ::Firebird::IUdrPlugin* udrPlugin) \
{ \ { \
::Firebird::Udr::FactoryRegistration::finish(status, udrPlugin); \ ::Firebird::Udr::FactoryRegistration::finish(status, udrPlugin); \

View File

@ -64,6 +64,18 @@
#define FB_API_DEPRECATED #define FB_API_DEPRECATED
#endif #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" #include "./firebird/impl/types_pub.h"
/***********************/ /***********************/

View File

@ -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, // ASF: We can't read config_info if version < INTL_VERSION_2,
// since it wasn't pushed in the stack by the engine. // 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, USHORT attributes, const UCHAR* specific_attributes,
ULONG specific_attributes_length, INTL_BOOL ignore_attributes, ULONG specific_attributes_length, INTL_BOOL ignore_attributes,
const ASCII* config_info) 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, const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo,
ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst) 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. // We support version 1 and 2.
if (*version != INTL_VERSION_1) if (*version != INTL_VERSION_1)

View File

@ -55,14 +55,6 @@
#define UINT16 USHORT #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 */ /* Following this line is LD.H from Borland Language Driver Kit */

View File

@ -38,13 +38,13 @@ struct CsConvertImpl
extern USHORT version; extern USHORT version;
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);
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, USHORT attributes, const UCHAR* specific_attributes,
ULONG specific_attributes_length, INTL_BOOL ignore_attributes, ULONG specific_attributes_length, INTL_BOOL ignore_attributes,
const ASCII* config_info); const ASCII* config_info);
void FB_DLL_EXPORT LD_version(USHORT* version); FB_DLL_EXPORT void LD_version(USHORT* version);
ULONG FB_DLL_EXPORT LD_setup_attributes( FB_DLL_EXPORT ULONG LD_setup_attributes(
const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo, const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo,
ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst); ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst);

View File

@ -465,7 +465,7 @@ void registerEngine(IPluginManager* iPlugin)
} // namespace Jrd } // 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); CachedMasterInterface::set(master);
registerEngine(PluginManagerInterfacePtr()); registerEngine(PluginManagerInterfacePtr());

View File

@ -189,7 +189,7 @@ SimpleFactory<ChaCha<8> > factory64;
} // anonymous namespace } // 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); CachedMasterInterface::set(master);
PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_WIRE_CRYPT, "ChaCha", &factory); PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_WIRE_CRYPT, "ChaCha", &factory);

View File

@ -718,7 +718,7 @@ class IExternalEngineFactoryImpl : public SimpleFactory<Engine>
{ {
} factory; } 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); CachedMasterInterface::set(master);

View File

@ -1046,7 +1046,7 @@ void registerRedirector(Firebird::IPluginManager* iPlugin)
} // namespace Remote } // 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(); IPluginManager* pi = master->getPluginManager();
registerRedirector(pi); registerRedirector(pi);

View File

@ -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); Firebird::CachedMasterInterface::set(master);
registerTrace(Firebird::PluginManagerInterfacePtr()); registerTrace(Firebird::PluginManagerInterfacePtr());

View File

@ -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); 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 // Assume that line is not too long
char buffer[PRETTY_BUFFER_SIZE + 10]; char buffer[PRETTY_BUFFER_SIZE + 10];

View File

@ -134,8 +134,10 @@ SINT64 API_ROUTINE isc_portable_integer(const UCHAR*, SSHORT);
void gds__cleanup(); void gds__cleanup();
void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler); void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler);
void FB_EXPORTED gds__default_printer(void*, SSHORT, const TEXT*); // These functions uses cdecl convention in Windows, so use API_ROUTINE_VARARG instead of API_ROUTINE (stdcall).
void FB_EXPORTED gds__trace_printer(void*, SSHORT, const TEXT*); 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 #ifdef NOT_USED_OR_REPLACED
void gds__print_pool(Firebird::MemoryPool*, const TEXT*, ...); void gds__print_pool(Firebird::MemoryPool*, const TEXT*, ...);
#endif #endif