This adds REQUIRES: shared_cxxabi to a bunch of tests that would fail if this weak reference in sanitizer common was undefined. This is necessary in cases where libc++abi.a is statically linked in. Because there is no strong reference to __cxa_demangle in compiler-rt, then if libc++abi is linked in via a static archive, then the linker will not extract the archive member that would define that weak symbol. This causes a handful of tests to fail because this leads to the symbolizer printing mangled symbols where tests expect them demangled. Technically, this feature is WAI since sanitizer runtimes shouldn't fail if this symbol isn't resolved, and linking statically means you wouldn't need to link in all of libc++abi. As a workaround, we can simply make it a requirement that these tests use shared libc++abis. Differential Revision: https://reviews.llvm.org/D109639
42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
// Fails with debug checks: https://bugs.llvm.org/show_bug.cgi?id=46862
|
|
// XFAIL: !compiler-rt-optimized && !riscv64
|
|
|
|
// REQUIRES: shared_cxxabi
|
|
|
|
/// Not using private alias or enabling ODR indicator can detect ODR issues.
|
|
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm -asan-use-private-alias=0 %s -o %dynamiclib1
|
|
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared -mllvm -asan-use-private-alias=0 %s -o %dynamiclib2
|
|
// RUN: %clangxx_asan -fno-rtti %s %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t
|
|
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
|
|
|
|
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm -asan-use-odr-indicator=1 %s -o %dynamiclib1
|
|
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared -mllvm -asan-use-odr-indicator=1 %s -o %dynamiclib2
|
|
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
|
|
|
|
/// By default we can detect ODR issues in vtables.
|
|
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared %s -o %dynamiclib1
|
|
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared %s -o %dynamiclib2
|
|
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
|
|
|
|
struct XYZ {
|
|
virtual void foo();
|
|
};
|
|
|
|
#if defined(BUILD_SO1)
|
|
|
|
void XYZ::foo() {}
|
|
|
|
#elif defined(BUILD_SO2)
|
|
|
|
void XYZ::foo() {}
|
|
|
|
#else
|
|
|
|
int main() {}
|
|
|
|
#endif
|
|
|
|
// CHECK: AddressSanitizer: odr-violation
|
|
// CHECK-NEXT: 'vtable for XYZ'
|
|
// CHECK-NEXT: 'vtable for XYZ'
|