[PATCH] [ASan] Only include rpc headers if they are available.
Yury Gribov
tetra2005 at gmail.com
Thu Apr 2 11:06:31 PDT 2015
Updated based on Kostya's suggestions. Also performed more rigorous testing:
- rpc/xdr.h + tirpc/rpc/xdr.h - works
- only rpc/xdr.h - works
- only tirpc/rpc/xdr.h - works
- none - works
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8698
Files:
lib/sanitizer_common/CMakeLists.txt
lib/sanitizer_common/sanitizer_platform.h
lib/sanitizer_common/sanitizer_platform_limits_posix.cc
lib/sanitizer_common/sanitizer_platform_limits_posix.h
Index: lib/sanitizer_common/CMakeLists.txt
===================================================================
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -111,6 +111,18 @@
SANITIZER_NEEDS_SEGV=1)
endif()
+include(CheckIncludeFile)
+check_include_file(rpc/xdr.h HAVE_RPC_XDR_H)
+if (NOT HAVE_RPC_XDR_H)
+ set(HAVE_RPC_XDR_H 0)
+endif()
+list(APPEND SANITIZER_COMMON_DEFINITIONS HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
+check_include_file(tirpc/rpc/xdr.h HAVE_TIRPC_XDR_H)
+if (NOT HAVE_TIRPC_XDR_H)
+ set(HAVE_TIRPC_XDR_H 0)
+endif()
+list(APPEND SANITIZER_COMMON_DEFINITIONS HAVE_TIRPC_XDR_H=${HAVE_TIRPC_XDR_H})
+
set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_no_rtti_flag(SANITIZER_CFLAGS)
Index: lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform.h
+++ lib/sanitizer_common/sanitizer_platform.h
@@ -130,4 +130,11 @@
# define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 12)
#endif
+// Assume obsolete RPC headers are available by default
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && \
+ !defined(HAVE_RPC_XDR_H) && !defined(HAVE_TIRPC_XDR_H)
+# define HAVE_RPC_XDR_H 1
+# define HAVE_TIRPC_XDR_H 0
+#endif
+
#endif // SANITIZER_PLATFORM_H
Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -135,7 +135,11 @@
#include <netax25/ax25.h>
#include <netipx/ipx.h>
#include <netrom/netrom.h>
-#include <rpc/xdr.h>
+#if HAVE_RPC_XDR_H
+# include <rpc/xdr.h>
+#elif HAVE_TIRPC_XDR_H
+# include <tirpc/rpc/xdr.h>
+#endif
#include <scsi/scsi.h>
#include <sys/mtio.h>
#include <sys/kd.h>
@@ -1159,7 +1163,8 @@
CHECK_SIZE_AND_OFFSET(group, gr_gid);
CHECK_SIZE_AND_OFFSET(group, gr_mem);
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && \
+ (HAVE_RPC_XDR_H || HAVE_TIRPC_XDR_H)
CHECK_TYPE_SIZE(XDR);
CHECK_SIZE_AND_OFFSET(XDR, x_op);
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
Index: lib/sanitizer_common/sanitizer_platform_limits_posix.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -297,7 +297,6 @@
#endif
#if SANITIZER_LINUX && !SANITIZER_ANDROID
-
struct __sanitizer_XDR {
int x_op;
void *x_ops;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8698.23171.patch
Type: text/x-patch
Size: 2580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150402/eef18b74/attachment.bin>
More information about the llvm-commits
mailing list