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 sanitizer/55354] [asan] by default, the asan run-time should be linked statically, not dynamically
Date: Fri, 23 Nov 2012 08:14:00 -0000	[thread overview]
Message-ID: <bug-55354-4-HqtD3A0Wj1@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 #24 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-23 08:13:11 UTC ---
When I rebuild libtsan with -fPIE instead of -fPIC in the Makefile, and
g++ -shared -Wl,--whole-archive -o libtsanx.so libtsan.a -ldl -lpthread
(note that .libs/*.o are still built with -fPIC because libtool overrides those
flags and adds its -fPIC at the end), then this link fails with:
/usr/bin/ld: libtsan.a(tsan_rtl.o): relocation R_X86_64_TPOFF32 against
`_ZN6__tsan22cur_thread_placeholderE' can not be used when making a shared
object; recompile with -fPIC
libtsan.a(tsan_rtl.o): could not read symbols: Bad value
collect2: error: ld returned 1 exit status
(obviously, local-exec model would need to patch the insn at dynamic linking
time, making the library DT_TEXTREL (not acceptable for SELinux, not allowed
for x86_64 at all)).

Yes, I see the code generation differences, but the functions are huge anyway,
is it really so crucial that you'd want to make another libtsan_pie.a for it?

BTW, the tsan that was added to GCC yesterday doesn't have
-ftls-model=initial-exec even, so it is even slower.
-ftls-model=initial-exec can only be done for *-*-linux* targets btw, I don't
think other dynamic linkers support dlopening IE model shared libraries.
E.g. libgomp has in its configure.tgt
if test $gcc_cv_have_tls = yes ; then
  case "${target}" in

    *-*-linux*)
        XCFLAGS="${XCFLAGS} -ftls-model=initial-exec"
        ;;
  esac
fi

so libsanitizer/configure.tgt would need to add it to say TSAN_CXXFLAGS var
that would be substituted by configure.

Would be nice if you could check the numerous warnings from tsan build, e.g. it
seems the ALWAYS_INLINE macro doesn't include the inline keyword, and you are
using it on functions that don't have inline keyword, which gives a warning and
if it is inlined, it is by pure luck.  Either you should add inline keywords
manually, or put inline keyword into ALWAYS_INLINE macro.  There are other
warnings...


  parent reply	other threads:[~2012-11-23  8:14 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
2012-11-23  8:14 ` jakub at gcc dot gnu.org [this message]
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-HqtD3A0Wj1@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).