[PATCH] D60760: Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO

Stephan Bergmann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 16 01:08:10 PDT 2019


sberg created this revision.
sberg added reviewers: filcab, marxin, rsmith.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, kristof.beyls, javed.absar, kubamracek.
Herald added projects: clang, Sanitizers, LLVM.

This follows up after b7692bc3e9ad2691fc07261904b88fb15f30696b <https://reviews.llvm.org/rGb7692bc3e9ad2691fc07261904b88fb15f30696b> "[UBSan] Fix
isDerivedFromAtOffset on iOS ARM64" fixed the RTTI comparison in
isDerivedFromAtOffset on just one platform and then
a25a2c7c9a7e1e328a5bd8274d2d86b1fadc4692 <https://reviews.llvm.org/rGa25a2c7c9a7e1e328a5bd8274d2d86b1fadc4692> "Always compare C++ typeinfo (based on
libstdc++ implementation)" extended that fix to more platforms.

But there is another RTTI comparison for -fsanitize=function generated in
clang's CodeGenFunction::EmitCall as just a pointer comparison.  For
SANITIZER_NON_UNIQUE_TYPEINFO platforms this needs to be extended to also do
string comparison.  For that, __ubsan_handle_function_type_mismatch[_abort]
takes the two std::type_info pointers as additional parameters now, checks them
internally for potential equivalence, and returns without reporting failure if
they turn out to be equivalent after all.  (NORETURN needed to be dropped from
the _abort variant for that.)  Also these functions depend on ABI-specific RTTI
now, so needed to be moved from plain UBSAN_SOURCES (ubsan_handlers.h/cc) to
UBSAN_CXXABI_SOURCES (ubsan_handlers_cxx.h/cc), but as -fsanitize=function is
only supported in C++ mode that's not a problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60760

Files:
  clang/lib/CodeGen/CGExpr.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cc
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/lib/ubsan/ubsan_handlers_cxx.cc
  compiler-rt/lib/ubsan/ubsan_handlers_cxx.h
  compiler-rt/lib/ubsan/ubsan_type_hash.h
  compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc
  compiler-rt/lib/ubsan/ubsan_type_hash_win.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60760.195319.patch
Type: text/x-patch
Size: 8565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190416/c000d95d/attachment-0001.bin>


More information about the cfe-commits mailing list