[cfi] Do not emit bit set entry for available_externally vtables.

In the Itanium ABI, vtable may be emitted speculatively as an
available_externally global. Such vtable may not be present at the
link time and should not have a corresponding CFI bit set entry.

llvm-svn: 258596
This commit is contained in:
Evgeniy Stepanov 2016-01-23 01:20:18 +00:00
parent 9ea8033d1b
commit 93987df0fd
2 changed files with 16 additions and 1 deletions

View File

@ -1496,7 +1496,8 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT,
DC->getParent()->isTranslationUnit())
EmitFundamentalRTTIDescriptors();
CGM.EmitVTableBitSetEntries(VTable, VTLayout);
if (!VTable->isDeclarationForLinker())
CGM.EmitVTableBitSetEntries(VTable, VTLayout);
}
bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(

View File

@ -0,0 +1,14 @@
// Test that we don't emit a bit set entry for a speculative (available_externally) vtable.
// This does not happen in the Microsoft ABI.
// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck %s
class A {
public:
virtual ~A();
};
A a;
// CHECK: @_ZTV1A ={{.*}} available_externally
// CHECK-NOT: !{{.*}} = !{!{{.*}}, [4 x i8*]* @_ZTV1A, i64 16}