From: Mark Wooding Date: Tue, 1 Oct 2019 10:40:41 +0000 (+0100) Subject: Set ELF visibility to keep all of our external symbols to ourselves. X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/commitdiff_plain/26a7f37a5423cc8252d88ee8482f96b5692c0dce Set ELF visibility to keep all of our external symbols to ourselves. --- 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);