[PATCH] D11502: [UBSan] Fix isDerivedFromAtOffset on iOS ARM64
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 27 12:02:21 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262147: [UBSan] Fix isDerivedFromAtOffset on iOS ARM64 (authored by filcab).
Changed prior to commit:
http://reviews.llvm.org/D11502?vs=47094&id=49297#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11502
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc
compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg
compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp
compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h
compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp
Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp
===================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp
@@ -0,0 +1,10 @@
+// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -I%p/Helpers %p/Helpers/vptr-non-unique-typeinfo-lib.cpp -fPIC -shared -o %t-lib.so
+// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -I%p/Helpers -g %s -O3 -o %t %t-lib.so
+// RUN: %run %t
+
+#include "vptr-non-unique-typeinfo-lib.h"
+
+int main() {
+ X *px = libCall();
+ delete px;
+}
Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg
===================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg
@@ -0,0 +1,3 @@
+# Sources in this directory are helper files for tests which test functionality
+# involving multiple translation units.
+config.suffixes = []
Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h
===================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h
@@ -0,0 +1,4 @@
+struct X {
+ virtual ~X() {}
+};
+X *libCall();
Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp
===================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp
@@ -0,0 +1,5 @@
+#include "vptr-non-unique-typeinfo-lib.h"
+
+X *libCall() {
+ return new X;
+}
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
@@ -162,4 +162,10 @@
# define MSC_PREREQ(version) 0
#endif
+#if defined(__arm64__) && SANITIZER_IOS
+# define SANITIZER_NON_UNIQUE_TYPEINFO 1
+#else
+# define SANITIZER_NON_UNIQUE_TYPEINFO 0
+#endif
+
#endif // SANITIZER_PLATFORM_H
Index: compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc
===================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc
+++ compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc
@@ -115,7 +115,9 @@
static bool isDerivedFromAtOffset(const abi::__class_type_info *Derived,
const abi::__class_type_info *Base,
sptr Offset) {
- if (Derived->__type_name == Base->__type_name)
+ if (Derived->__type_name == Base->__type_name ||
+ (SANITIZER_NON_UNIQUE_TYPEINFO &&
+ !internal_strcmp(Derived->__type_name, Base->__type_name)))
return Offset == 0;
if (const abi::__si_class_type_info *SI =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11502.49297.patch
Type: text/x-patch
Size: 3275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160227/e467aceb/attachment.bin>
More information about the llvm-commits
mailing list