When building a shared library, ld warned of DT_TEXTREL (text relocations). This has been isolated to a relocation of typeinfo data that occurs only when -fsanitize contains ubsan. This occurs with both -stdlib=libc++ and -stdlib=libstdc++. Test case: #include <memory> std::shared_ptr<int> foo; // __END__ Reproducible: Always Steps to Reproduce: 1) Let the test case be named foo.cc. 2) clang -std=c++11 -fsanitize=undefined -fPIC -c foo.cc 3) clang -shared -fPIC foo.o foo.so Actual Results: (-stdlib=libc++): /usr/bin/x86_64-pc-linux-gnu-ld: a.o: warning: relocation against `typeinfo for void ()' in readonly section `.text.std::__1::shared_ptr<int>::~shared_ptr()[std::__1::shared_ptr<int>::~shared_ptr()]'. /usr/bin/x86_64-pc-linux-gnu-ld: warning: creating a DT_TEXTREL in object. (-stdlib=libstdc++): /usr/bin/x86_64-pc-linux-gnu-ld: a.o: warning: relocation against `typeinfo for int ()' in readonly section `.text'. /usr/bin/x86_64-pc-linux-gnu-ld: warning: creating a DT_TEXTREL in object. Expected Results: <no output>
Created attachment 396760 [details] emerge --info
Tried -fno-rtti to see whether typeinfo emission could be removed; got: x86_64-pc-linux-gnu-clang-3.5.1: error: invalid argument '-fsanitize=vptr' not allowed with '-fno-rtti' So it appears that the vptr sanitizer injects a non-PICable typeinfo, at least for elf-x86_64.
I can't reproduce it with current versions of clang. It's highly likely it has been fixed upstream.