From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 660464696C3 for ; Thu, 16 Apr 2020 02:15:47 +0300 (MSK) Received: by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1jOrFy-0002Kg-GY for tarantool-patches@dev.tarantool.org; Thu, 16 Apr 2020 02:15:46 +0300 From: Vladislav Shpilevoy References: Message-ID: <71863e35-1d40-bb2e-f792-ded289f0f807@tarantool.org> Date: Thu, 16 Apr 2020 01:15:45 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 00/43] Unhide symbols List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org 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 + +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.