[PATCH] Make sanitizers' interceptors non-weak on FreeBSD

Viktor Kutuzov vkutuzov at accesssoftek.com
Thu Jul 10 02:25:25 PDT 2014


Closed by commit rL212693 (authored by vkutuzov).

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D4418

Files:
  compiler-rt/trunk/lib/interception/interception.h

Index: compiler-rt/trunk/lib/interception/interception.h
===================================================================
--- compiler-rt/trunk/lib/interception/interception.h
+++ compiler-rt/trunk/lib/interception/interception.h
@@ -135,6 +135,16 @@
     extern "C" ret_type func(__VA_ARGS__);
 # define DECLARE_WRAPPER_WINAPI(ret_type, func, ...) \
     extern "C" __declspec(dllimport) ret_type __stdcall func(__VA_ARGS__);
+#elif defined(__FreeBSD__)
+# define WRAP(x) __interceptor_ ## x
+# define WRAPPER_NAME(x) "__interceptor_" #x
+# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default")))
+// 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 WRAP(x) __interceptor_ ## x
 # define WRAPPER_NAME(x) "__interceptor_" #x
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4418.11250.patch
Type: text/x-patch
Size: 1075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140710/cd7f244e/attachment.bin>


More information about the llvm-commits mailing list