[PATCH] Make sanitizers' interceptors non-weak on FreeBSD
Viktor Kutuzov
vkutuzov at accesssoftek.com
Tue Jul 8 05:20:30 PDT 2014
Hi kcc, samsonov,
Related discussion:
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=16483939+0+current/freebsd-current
http://reviews.llvm.org/D4418
Files:
lib/interception/interception.h
Index: lib/interception/interception.h
===================================================================
--- lib/interception/interception.h
+++ lib/interception/interception.h
@@ -139,9 +139,19 @@
# define WRAP(x) __interceptor_ ## x
# define WRAPPER_NAME(x) "__interceptor_" #x
# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default")))
-# define DECLARE_WRAPPER(ret_type, func, ...) \
- extern "C" ret_type func(__VA_ARGS__) \
- __attribute__((weak, alias("__interceptor_" #func), visibility("default")));
+# if defined(__FreeBSD__)
+// FreeBSD's dynamic linker (incompliantly) gives non-weak symbols higher
+// priority than weak ones so weak aliases won't work for indirect calls
+// in position-independent (-fPIC / -fPIE) mode.
+# define DECLARE_WRAPPER(ret_type, func, ...) \
+ extern "C" ret_type func(__VA_ARGS__) \
+ __attribute__((alias("__interceptor_" #func), visibility("default")));
+# else
+# define DECLARE_WRAPPER(ret_type, func, ...) \
+ extern "C" ret_type func(__VA_ARGS__) \
+ __attribute__((weak, alias("__interceptor_" #func), \
+ visibility("default")));
+# endif
#endif
#if !defined(__APPLE__)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4418.11154.patch
Type: text/x-patch
Size: 1171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140708/8663d13c/attachment.bin>
More information about the llvm-commits
mailing list