GCC 5.3: UBSAN versus -static-libstdc++

Marc Glisse marc.glisse@inria.fr
Fri Dec 18 20:46:00 GMT 2015


On Fri, 18 Dec 2015, Paul Smith wrote:

> Hi all.  I normally build my code with -static-libgcc and -static
> -libstdc++, so I don't need to worry about compiler and stdc++ library
> versions when I copy programs around.  I don't link with any other (non
> -locally-built) C++ code so it works for me.
>
> I'm using GNU/Linux with a version of GCC 5.3.0 / binutils 2.25.1 that
> I built myself locally, and it works in all other respects.
>
> However today I decided to try to add -fsanitize=undefined to my
> compile and link lines, and this caused my link to fail with errors
> such as:
>
> /tools/cc/generic/bin/../lib/gcc/x86_64-generic-linux
> -gnu/5.3.0/../../../../x86_64-generic-linux
> -gnu/lib/../lib64/libubsan.a(ubsan_type_hash.o): In function
> `findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)':
> (.text+0x3c): undefined reference to `__dynamic_cast'
>
> If I remove the -static-libstdc++ flag then it links fine.
>
> I have used other sanitizers like ASAN for a long time, with static
> libstdc++, with no problems.
>
>
> Is it just the case that UBSAN cannot work with static libstdc++?  Or
> is my local installation of GCC 5.3 deficient somehow?  Or is this a
> bug that I should report?

I guess you could call it a bug that -lubsan ends up after -lstdc++ in the 
linker command. Please add -v to your command line and include what it 
prints in your bug report (assuming there isn't already one, I didn't 
look).

-- 
Marc Glisse



More information about the Gcc-help mailing list