public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dvyukov at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/55354] [asan] by default, the asan run-time should be linked statically, not dynamically
Date: Fri, 23 Nov 2012 07:28:00 -0000	[thread overview]
Message-ID: <bug-55354-4-BPwSo6OGqP@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 #23 from Dmitry Vyukov <dvyukov at google dot com> 2012-11-23 07:27:27 UTC ---
(In reply to comment #21)
> (In reply to comment #20)
> > What I see is that it also affect code generation (register allocation). Do we
> > need to file a bug on that?
> 
> If you see a code generation difference even with -ftls-model=local-exec -fPIC
> vs. -fPIE, then it must mean you don't have visibility attributes on the
> symbols used in the fast path.  For initial-exec, the RA effects should be
> minimal, the TLS offset load from got is usually very close to the actual TLS
> memory load (or lea), and thus it will just pick up some short lived scratch
> register.  Generally in GCC, -fPIE sets flag_pic and not flag_shlib, while
> -fPIC sets flag_pic and flag_shlib.  flag_pic is about whether position
> independent code needs to be generated, flag_shlib is about whether locally
> defined symbols can be interposed (plus it affects TLS model default choice).

When I compile with -fvisibility=hidden, it does not affect generated code.
It's not that we access a lot of symbols in the function, there is one
thread-local and one static global var.

That "minimal" RA effects do have effect in our case. We don't have a reserve
to squeeze another register for tls access:

// -fPIE
000000000009ca30 <__tsan_write2>:
   9ca30:       64 48 8b 04 25 40 1f    mov    %fs:0xffffffffffeb1f40,%rax
   9ca37:       eb ff 
   9ca39:       48 8b 0c 24             mov    (%rsp),%rcx
   9ca3d:       a8 01                   test   $0x1,%al
   9ca3f:       0f 85 d3 00 00 00       jne    9cb18 <__tsan_write2+0xe8>
   9ca45:       48 83 e8 80             sub    $0xffffffffffffff80,%rax
   9ca49:       48 89 fe                mov    %rdi,%rsi
   9ca4c:       48 89 c2                mov    %rax,%rdx
   9ca4f:       64 48 89 04 25 40 1f    mov    %rax,%fs:0xffffffffffeb1f40
   9ca56:       eb ff 

// -fPIC -ftls-model=initial-exec
00000000000969f0 <__tsan_write2>:
   969f0:       48 c7 c2 40 1f eb ff    mov    $0xffffffffffeb1f40,%rdx
   969f7:       53                      push   %rbx
   969f8:       48 8b 4c 24 08          mov    0x8(%rsp),%rcx
   969fd:       64 48 8b 02             mov    %fs:(%rdx),%rax
   96a01:       a8 01                   test   $0x1,%al
   96a03:       0f 85 c7 00 00 00       jne    96ad0 <__tsan_write2+0xe0>


  parent reply	other threads:[~2012-11-23  7:28 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
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 [this message]
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-BPwSo6OGqP@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: link
Be 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).