From 26a7f37a5423cc8252d88ee8482f96b5692c0dce Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 1 Oct 2019 11:40:41 +0100 Subject: [PATCH] Set ELF visibility to keep all of our external symbols to ourselves. --- catacomb-python.h | 15 +++++++++++++++ catacomb.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/catacomb-python.h b/catacomb-python.h index df29099..5815343 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -120,6 +120,21 @@ #include #include +/*----- Other preliminaries -----------------------------------------------*/ + +#define GOBBLE_SEMI extern int notexist +#if defined(__GNUC__) && defined(__ELF__) +# define PRIVATE_SYMBOLS _Pragma("GCC visibility push(hidden)") GOBBLE_SEMI +# define PUBLIC_SYMBOLS _Pragma("GCC visibility pop") GOBBLE_SEMI +# define EXPORT __attribute__((__visibility__("default"))) +#else +# define PRIVATE_SYMBOLS GOBBLE_SEMI +# define PUBLIC_SYMBOLS GOBBLE_SEMI +# define EXPORT +#endif + +PRIVATE_SYMBOLS; + /*----- Utility macros ----------------------------------------------------*/ #define RETURN_OBJ(obj) do { Py_INCREF(obj); return (obj); } while (0) diff --git a/catacomb.c b/catacomb.c index b596b5e..affb5d3 100644 --- a/catacomb.c +++ b/catacomb.c @@ -167,7 +167,7 @@ static void init_random(void) #endif } -void init_base(void) +EXPORT void init_base(void) { PyObject *mod; addmethods(methods); -- 2.11.0