From 2d8afb982ad65bc176c9044aff99dbd85556ec57 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 12 Jan 2020 10:36:01 +0100 Subject: [PATCH] test: export public symbols in addons tests Upcoming changes to node-gyp will turn on `-fvisibility=hidden` on macOS. Ensure that public symbols that are dlsym'd have default visibility. Refs: https://github.com/nodejs/node/pull/28647 Refs: https://github.com/nodejs/node-gyp/pull/1828 PR-URL: https://github.com/nodejs/node/pull/28717 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- test/addons/dlopen-ping-pong/binding.cc | 4 +++- test/addons/dlopen-ping-pong/ping.c | 1 + test/addons/openssl-client-cert-engine/testengine.cc | 10 ++++++++-- test/addons/openssl-key-engine/testkeyengine.cc | 10 ++++++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/test/addons/dlopen-ping-pong/binding.cc b/test/addons/dlopen-ping-pong/binding.cc index ecdabd5e0f4eef..7b211be1195bf7 100644 --- a/test/addons/dlopen-ping-pong/binding.cc +++ b/test/addons/dlopen-ping-pong/binding.cc @@ -5,7 +5,9 @@ #include -extern "C" const char* dlopen_pong(void) { +extern "C" +__attribute__((visibility("default"))) +const char* dlopen_pong(void) { return "pong"; } diff --git a/test/addons/dlopen-ping-pong/ping.c b/test/addons/dlopen-ping-pong/ping.c index bb0e6845d54466..c76f40580c4168 100644 --- a/test/addons/dlopen-ping-pong/ping.c +++ b/test/addons/dlopen-ping-pong/ping.c @@ -2,6 +2,7 @@ const char* dlopen_pong(void); +__attribute__((visibility("default"))) const char* dlopen_ping(void) { return dlopen_pong(); } diff --git a/test/addons/openssl-client-cert-engine/testengine.cc b/test/addons/openssl-client-cert-engine/testengine.cc index 078695a0566691..7ccb56e08015a7 100644 --- a/test/addons/openssl-client-cert-engine/testengine.cc +++ b/test/addons/openssl-client-cert-engine/testengine.cc @@ -19,6 +19,12 @@ #define AGENT_KEY "test/fixtures/keys/agent1-key.pem" #define AGENT_CERT "test/fixtures/keys/agent1-cert.pem" +#ifdef _WIN32 +# define DEFAULT_VISIBILITY __declspec(dllexport) +#else +# define DEFAULT_VISIBILITY __attribute__((visibility("default"))) +#endif + namespace { int EngineInit(ENGINE* engine) { @@ -93,8 +99,8 @@ int bind_fn(ENGINE* engine, const char* id) { } extern "C" { - IMPLEMENT_DYNAMIC_CHECK_FN(); - IMPLEMENT_DYNAMIC_BIND_FN(bind_fn); + DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_CHECK_FN(); + DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_BIND_FN(bind_fn); } } // anonymous namespace diff --git a/test/addons/openssl-key-engine/testkeyengine.cc b/test/addons/openssl-key-engine/testkeyengine.cc index 78a4fc49a63e83..e1dc22164ac4c1 100644 --- a/test/addons/openssl-key-engine/testkeyengine.cc +++ b/test/addons/openssl-key-engine/testkeyengine.cc @@ -18,6 +18,12 @@ #define PRIVATE_KEY "test/fixtures/keys/agent1-key.pem" +#ifdef _WIN32 +# define DEFAULT_VISIBILITY __declspec(dllexport) +#else +# define DEFAULT_VISIBILITY __attribute__((visibility("default"))) +#endif + namespace { int EngineInit(ENGINE* engine) { @@ -66,8 +72,8 @@ int bind_fn(ENGINE* engine, const char* id) { } extern "C" { - IMPLEMENT_DYNAMIC_CHECK_FN(); - IMPLEMENT_DYNAMIC_BIND_FN(bind_fn); + DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_CHECK_FN(); + DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_BIND_FN(bind_fn); } } // anonymous namespace