public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <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: Wed, 21 Nov 2012 08:43:00 -0000	[thread overview]
Message-ID: <bug-55354-4-7aNraynPQw@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 #19 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-21 08:40:52 UTC ---
(In reply to comment #18)
> For actual ThreadSanitizer runtime -fPIC -ftls-model=initial-exec causes
> degradation of generated code. Linker emits the same tls access code in all
> cases, but the compiler generates worse code.

-fPIC -ftls-model=initial-exec is by definition almost equivalent to -fPIE, the
only exceptions are:
1) -fPIE code is allowed to assume globally visible symbols aren't interposed
2) if TLS vars are defined locally (or hidden visibility), then local-exec
   model can be used instead of initial-exec (one less dereference)

As for 2), I've explained already that by linking -fPIC code into the
executable if the TLS var is defined in the executable, linker TLS transition
transform all other TLS models (even global and local dynamic) into local-exec,
just might result in some nops or for IE->LE setting of a register to an
immediate and using that register as opposed to just using the immediate in the
%fs: prefixed insn.

And for 1), for the fast path, for any symbols on the fast path that shouldn't
be interposeable and that are defined in libtsan, you should be able to just
use visibility attributes and get the same effect.

-fPIE flag simply isn't usable for a library that is to be used also by shared
libraries.  How do you link -fsanitize=thread shared libraries anyway?  Just
don't link libtsan in for -static-libtsan, and rely on the executable being
linked against it?  Such libraries will fail to link with -Wl,-z,defs ...
Of course, having multiple tsan TLS roots in the same process isn't a good idea
either (which is why I think we can't default to -static-libtsan).


  parent reply	other threads:[~2012-11-21  8:43 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 [this message]
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-7aNraynPQw@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).