public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/64998] New: -shared -static-libasan does not actually link libasan
@ 2015-02-10 11:48 holger.grund@ix-n.net
  2015-03-10  9:20 ` [Bug driver/64998] " jakub at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: holger.grund@ix-n.net @ 2015-02-10 11:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64998

            Bug ID: 64998
           Summary: -shared -static-libasan does not actually link libasan
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: holger.grund@ix-n.net

It was my expectation that I could statically link libasan into a shared object
with:

$ cat t.c
void foo(char* x) { x[4] = 1; }
$ gcc -fsanitize=address t.c -shared -fPIC -static-libasan

However, it seems that -lasan is never passed to the linker and I end up with
lots of unresolved symbols:

$ readelf -s a.out | grep asan
     9: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __asan_init_v3
    10: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __asan_report_store1
    51: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __asan_init_v3
    52: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __asan_report_store1

$ gcc -fsanitize=address t.c -shared -fPIC -static-libasan
-Wl,-Bstatic,-lasan,-Bdynamic

seems to produce the expected output.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug driver/64998] -shared -static-libasan does not actually link libasan
  2015-02-10 11:48 [Bug driver/64998] New: -shared -static-libasan does not actually link libasan holger.grund@ix-n.net
@ 2015-03-10  9:20 ` jakub at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-10  9:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64998

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah, you don't want multiple libasan runtimes in multiple shared libraries or
shared library and executable, which is why -static-libasan links it only into
the executable.
You really should link -lasan dynamically ;).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-10  9:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-10 11:48 [Bug driver/64998] New: -shared -static-libasan does not actually link libasan holger.grund@ix-n.net
2015-03-10  9:20 ` [Bug driver/64998] " jakub at gcc dot gnu.org

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).