Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 540426 - sys-devel/llvm-3.5.1: clang, UndefinedBehaviorSanitizer produces non-PIC output when using std::shared_ptr
Summary: sys-devel/llvm-3.5.1: clang, UndefinedBehaviorSanitizer produces non-PIC outp...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-17 22:09 UTC by Andrey Vul
Modified: 2018-03-29 07:49 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (file_540426.txt,23.87 KB, text/plain)
2015-02-17 22:10 UTC, Andrey Vul
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Vul 2015-02-17 22:09:46 UTC
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>
Comment 1 Andrey Vul 2015-02-17 22:10:09 UTC
Created attachment 396760 [details]
emerge --info
Comment 2 Andrey Vul 2015-02-17 22:17:55 UTC
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.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-03-29 07:49:33 UTC
I can't reproduce it with current versions of clang. It's highly likely it has been fixed upstream.