[Tarantool-patches] [PATCH 00/43] Unhide symbols
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Thu Apr 16 02:15:45 MSK 2020
With help of Timur there was a discovered a little less
intrusive solution: a little hack with the compiler.
Consider this diff:
====================
diff --git a/src/exports.c b/src/exports.c
index de1892026..47fe1b9bd 100644
--- a/src/exports.c
+++ b/src/exports.c
@@ -30,6 +30,11 @@
*/
#define EXPORT(func) extern void ** func(void)
+#include <time.h>
+
+extern void *bit_unused_function;
+extern void *bit_symbol;
+
/**
* The file is a hack to force the linker keep the needed symbols
* in the result tarantool executable file.
@@ -121,6 +126,11 @@ export_syms(void)
const int func_count = sizeof(syms) / sizeof(syms[0]);
for (int i = 0; i < func_count; ++i)
((void **(*)(void))syms[i])();
+ if (time(NULL) == 0)
+ {
+ ((void **(*)(void))bit_unused_function)();
+ ((void **(*)(void))bit_symbol)();
+ }
}
#undef EXPORT
diff --git a/src/lib/bit/bit.c b/src/lib/bit/bit.c
index 72cc94dc3..94fe75408 100644
--- a/src/lib/bit/bit.c
+++ b/src/lib/bit/bit.c
@@ -31,6 +31,15 @@
#include "bit/bit.h"
+void
+bit_unused_function(void)
+{
+ printf("Unused\n");
+ return;
+}
+
+int bit_symbol = 0;
+
extern inline uint8_t
load_u8(const void *p);
====================
As you can see, I managed to reference the needed symbols from a
static library without doing any includes. It means, we can
resurrect ffi_syms.c like it was before, but in a much simpler
manner, with 0 dependencies. Only extern void * of needed
variables and functions.
More information about the Tarantool-patches
mailing list