From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14632 invoked by alias); 18 Nov 2012 19:54:58 -0000 Received: (qmail 14217 invoked by uid 48); 18 Nov 2012 19:54:40 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/55354] [asan] by default, the asan run-time should be linked statically, not dynamically Date: Sun, 18 Nov 2012 19:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg01671.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55354 --- Comment #10 from Jakub Jelinek 2012-11-18 19:54:37 UTC --- (In reply to comment #9) > NOT-SO-BAD: -fPIC -shared -ftls-model=initial-exec > % gcc x.c -O2 -fPIC -shared -o x.so -ftls-model=initial-exec ; objdump -d x.so > | grep foo.: -A 5 > 0000000000000630 : > 630: 48 8b 05 a9 09 20 00 mov 0x2009a9(%rip),%rax # 200fe0 > <_DYNAMIC+0x1b8> > 637: 64 8b 00 mov %fs:(%rax),%eax > 63a: c3 retq > > > GOOD: -fPIE > % gcc -c x.c -O2 -fPIE -o x.o ; objdump -d x.o | grep foo.: -A 5 > 0000000000000000 : > 0: 64 8b 04 25 00 00 00 mov %fs:0x0,%eax > 7: 00 > 8: c3 retq > > > So, while -ftls-model=initial-exec improves the TLS performance, it is still > 2x slower than -fPIE. Except obviously you can't use the last code sequence if you want to link it into a shared library. The extra indirection is the standard cost of relocatable code, especially if there are just a few TLS vars in libtsan and they are accessed a lot, that memory (the .got section entry) is in caches most likely and so the indirection can be just a cycle or at most a few of them. No idea how would you plan to compile libtsan with -fPIE flag, for libtsan.so.0 you obviously can't, it would fail to link or load, and for libtsan.a it would make the shared library only usable in executables or PIEs, not from shared libraries.