public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "konstantin.s.serebryany at gmail dot com" <gcc-bugzilla@gcc.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:36:00 -0000 [thread overview] Message-ID: <bug-55354-4-izAWMNN2vX@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55354-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55354 --- Comment #9 from Konstantin Serebryany <konstantin.s.serebryany at gmail dot com> 2012-11-18 19:35:43 UTC --- As dvyuokv@ pointed out, -ftls-model=initial-exec improves the situation, but does not fully help. Experiment: % cat x.c __thread int a; int foo() { return a; } HORRIBLE: -fPIC -shared % gcc x.c -O2 -fPIC -shared -o x.so ; objdump -d x.so | grep foo.: -A 5 00000000000006e0 <foo>: 6e0: 66 48 8d 3d f0 08 20 lea 0x2008f0(%rip),%rdi # 200fd8 <_DYNAMIC+0x1b8> 6e7: 00 6e8: 66 66 48 e8 10 ff ff callq 600 <__tls_get_addr@plt> 6ef: ff 6f0: 8b 00 mov (%rax),%eax 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 <foo>: 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 <foo>: 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. For tsan, which does this for *every* memory access in the original program, this will cost 5%-10% slowdown. For our users this is a big deal, so they will link the static library whenever possible. Which default is used in gcc -- I don't care that much.
next prev parent reply other threads:[~2012-11-18 19:36 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-16 17:03 [Bug other/55354] New: " konstantin.s.serebryany at gmail dot com 2012-11-16 17:15 ` [Bug other/55354] " pinskia at gcc dot gnu.org 2012-11-16 17:21 ` dvyukov at google dot com 2012-11-16 17:22 ` jakub at gcc dot gnu.org 2012-11-16 20:28 ` konstantin.s.serebryany at gmail dot com 2012-11-16 20:47 ` jakub at gcc dot gnu.org 2012-11-16 20:54 ` konstantin.s.serebryany at gmail dot com 2012-11-17 20:36 ` hjl.tools at gmail dot com 2012-11-17 21:08 ` markus at trippelsdorf dot de 2012-11-18 19:36 ` konstantin.s.serebryany at gmail dot com [this message] 2012-11-18 19:54 ` jakub at gcc dot gnu.org 2012-11-18 19:59 ` konstantin.s.serebryany at gmail dot com 2012-11-18 20:10 ` jakub at gcc dot gnu.org 2012-11-19 4:13 ` konstantin.s.serebryany at gmail dot com 2012-11-19 8:55 ` jakub at gcc dot gnu.org 2012-11-19 9:03 ` konstantin.s.serebryany at gmail dot com 2012-11-19 9:06 ` konstantin.s.serebryany at gmail dot com 2012-11-19 10:53 ` dvyukov at google dot com 2012-11-21 7:45 ` dvyukov at google dot com 2012-11-21 8:43 ` jakub at gcc dot gnu.org 2012-11-21 9:06 ` dvyukov at google dot com 2012-11-21 9:26 ` jakub at gcc dot gnu.org 2012-11-23 7:17 ` [Bug sanitizer/55354] " dvyukov at google dot com 2012-11-23 7:28 ` dvyukov at google dot com 2012-11-23 8:14 ` jakub at gcc dot gnu.org 2012-11-23 8:22 ` jakub at gcc dot gnu.org 2012-11-23 8:36 ` dvyukov at google dot com 2012-11-23 10:47 ` konstantin.s.serebryany at gmail dot com 2012-11-23 11:16 ` konstantin.s.serebryany at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-55354-4-izAWMNN2vX@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).