2

我建立vfptr.cpp一个fsanitize=vptr文件static。它有关于“未定义的 __dynamic_cast 引用”的错误消息。g++7.4.0 和 g++11.0.0 都有问题。使用 sanitizer=vptr 是否合理?

vptr.cpp

struct A {
  virtual ~A() {};
};

int main() { A a; }

编译选项

g++ vptr.C -fsanitize=vptr -static

错误信息:

/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long)':
(.text+0x52): undefined reference to `__dynamic_cast'
(.text+0x5e): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
(.text+0x6b): undefined reference to `__dynamic_cast'
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)':
(.text+0x151): undefined reference to `__dynamic_cast'
(.text+0x15d): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
(.text+0x16a): undefined reference to `__dynamic_cast'
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `__ubsan::checkDynamicType(void*, void*, unsigned long)':
(.text+0x293): undefined reference to `__dynamic_cast'
collect2: error: ld returned 1 exit status
4

0 回答 0