From ef4f97648dc95849e417dd3e6328165de4c22185 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 26 Aug 2016 22:40:27 +0200 Subject: malloc: Simplify static malloc interposition [BZ #20432] Existing interposed mallocs do not define the glibc-internal fork callbacks (and they should not), so statically interposed mallocs lead to link failures because the strong reference from fork pulls in glibc's malloc, resulting in multiple definitions of malloc-related symbols. --- include/libc-symbols.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/libc-symbols.h') diff --git a/include/libc-symbols.h b/include/libc-symbols.h index c2b499a..e362d42 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -121,6 +121,21 @@ # define weak_extern(symbol) _weak_extern (weak symbol) # define _weak_extern(expr) _Pragma (#expr) +/* In shared builds, the expression call_function_static_weak + (FUNCTION-SYMBOL, ARGUMENTS) invokes FUNCTION-SYMBOL (an + identifier) unconditionally, with the (potentially empty) argument + list ARGUMENTS. In static builds, if FUNCTION-SYMBOL has a + definition, the function is invoked as before; if FUNCTION-SYMBOL + is NULL, no call is performed. */ +# ifdef SHARED +# define call_function_static_weak(func, ...) func (__VA_ARGS__) +# else /* !SHARED */ +# define call_function_static_weak(func, ...) \ + ({ \ + extern __typeof__ (func) func weak_function; \ + (func != NULL ? func (__VA_ARGS__) : (void)0); \ + }) +# endif #else /* __ASSEMBLER__ */ -- cgit v1.1