chiark / gitweb /
Set ELF visibility to keep all of our external symbols to ourselves.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 1 Oct 2019 10:40:41 +0000 (11:40 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 1 Oct 2019 20:51:10 +0000 (21:51 +0100)
algorithms.c
catacomb-python.h
catacomb.c
rand.c

index d73981e252f0e5a0c8de0a2d29bee7d9b48bce0d..e6dbe21a98b0768b01e5095f59a222c1b6e04426 100644 (file)
@@ -27,7 +27,9 @@
 /*----- Header files ------------------------------------------------------*/
 
 #include "catacomb-python.h"
+PUBLIC_SYMBOLS;
 #include "algorithms.h"
+PRIVATE_SYMBOLS;
 
 /*----- Key sizes ---------------------------------------------------------*/
 
index df29099b2d85ad343f90b65fc68303adbccd5916..5815343e5c11c616200d4c2804e173baf5124e27 100644 (file)
 #include <catacomb/share.h>
 #include <catacomb/gfshare.h>
 
+/*----- 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)
index b596b5ec062c5b646f442880b9fe19bf799eac17..affb5d3e88509461c57d756ea8102b8337cc7479 100644 (file)
@@ -167,7 +167,7 @@ static void init_random(void)
 #endif
 }
 
-void init_base(void)
+EXPORT void init_base(void)
 {
   PyObject *mod;
   addmethods(methods);
diff --git a/rand.c b/rand.c
index 9afb271c86b26e17bf02e0ff5c6b01d4cf4419c8..15a07880aac14824313214e16f75eb77315155e7 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -27,7 +27,9 @@
 /*----- Header files ------------------------------------------------------*/
 
 #include "catacomb-python.h"
+PUBLIC_SYMBOLS;
 #include "algorithms.h"
+PRIVATE_SYMBOLS;
 
 /*----- Main code ---------------------------------------------------------*/