Skip to content

Commit

Permalink
test: export public symbols in addons tests
Browse files Browse the repository at this point in the history
Upcoming changes to node-gyp will turn on `-fvisibility=hidden` on
macOS. Ensure that public symbols that are dlsym'd have default
visibility.

Refs: #28647
Refs: nodejs/node-gyp#1828

PR-URL: #28717
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
bnoordhuis authored and codebytere committed Feb 17, 2020
1 parent d770998 commit 0bafb5c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion test/addons/dlopen-ping-pong/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#include <dlfcn.h>

extern "C" const char* dlopen_pong(void) {
extern "C"
__attribute__((visibility("default")))
const char* dlopen_pong(void) {
return "pong";
}

Expand Down
1 change: 1 addition & 0 deletions test/addons/dlopen-ping-pong/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const char* dlopen_pong(void);

__attribute__((visibility("default")))
const char* dlopen_ping(void) {
return dlopen_pong();
}
Expand Down
10 changes: 8 additions & 2 deletions test/addons/openssl-client-cert-engine/testengine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
10 changes: 8 additions & 2 deletions test/addons/openssl-key-engine/testkeyengine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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

0 comments on commit 0bafb5c

Please sign in to comment.