Re: Undefined reference to `__dynamic_cast' when compiling with `-fsantize=vptr -static'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 1 Sep 2020 at 07:47, <eddiekuo@xxxxxxxxxxxxx> wrote:
>
> I compiled the following cpp file with `-fsantize=vptr -static'.
>
> struct A {
>   virtual ~A() {};
> };
>
> int main() { A a; }
>
> There would have the following output error:
> /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'
>
> There has a same result with gcc11.0.0.
> Is it a correct behavior for C++?

No. The problem is that libubsan requires symbols from libstdc++.so
(or libsupc++.a) but comes after it in the link line:

-lstdc++ -lm -lubsan -ldl -lrt -lpthread -lm --start-group -lgcc
-lgcc_eh -lc --end-group

Please report a bug, https://gcc.gnu./org/bugs/



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux