This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug driver/64998] New: -shared -static-libasan does not actually link libasan


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]