Open GoogleCodeExporter opened 9 years ago
Update the tests with
#PASS
clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so -Wl,--no-undefined
#PASS
g++-4.9 -shared -fPIC libtest.cpp -o libtest.so -Wl,--no-undefined
And I find for my built toolchain mipsel-linux-g++, everything works fine with
these two flags.
Original comment by xiaoyur...@gmail.com
on 9 Mar 2015 at 9:32
Attachments:
There are a few other linker flags that will not work with -fsanitize=* (e.g.
-z,defs).
--no-undefined is not any kind of special here and I think that the right
solution is
just not to use it.
Other ideas?
Original comment by konstant...@gmail.com
on 9 Mar 2015 at 5:23
For ubuntu GCC, it works when
"g++-4.9 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address -lasan".
And for my build toolchain(mips gcc 4.9), it works when
"mipsel-linux-g++ -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address
-fstack-protector".
"-lasan" flag isn't needed at all.
I guess maybe the asan build for ubuntu-toolchain-r doesn't add "-lasan" for
"-fsanitize=address" by default.
For clang, maybe the problem is that the clang only compile asan static
libraries, like
/usr/lib/llvm-3.6/lib/clang/3.6.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
/usr/lib/llvm-3.6/lib/clang/3.6.0/lib/linux/libclang_rt.asan-x86_64.a
As https://code.google.com/p/address-sanitizer/wiki/AsanAsDso says, "Until
recently, ASAN runtime in Clang on Linux was offered only in the form of static
library (e.g. libclang_rt.asan-x86_64.a). This has recently been changed and
you can now ask for shared runtime (aka ASAN-DSO) by cmaking with
-DCOMPILER_RT_BUILD_SHARED_ASAN=ON (and then compiling your code with
-fsanitize=address -shared-libasan)."
I find the link flag "-Wl,--no-undefined" which used by Android is nice, which
can avoid libraries developers forgeting to write the dependent libraries of
the library in the Makefile or CMakeLists.txt. So, I hope there is a way to use
both flags.
My solution is the following:
(1)For GCC, I use "-Wl,--no-undefined" and "-fsanitize=address" both, if the
linker fails, add "-lasan" for linker flag.
(2)For Clang Ubuntu, I use "-Wl,--no-undefined" by default. If
"-fsanitize=address" is set, turn off the flag "-Wl,--no-undefined".
(3)For Android NDK, since both static and shared libraries are built for asan,
both flags work fine, which I have approved for NDK r10d clang3.5.
Original comment by xiaoyur...@gmail.com
on 10 Mar 2015 at 2:01
> There are a few other linker flags that will not work
> with -fsanitize=* (e.g. -z,defs).
Kostya, do you have a complete list? We should probably add this to FAQ and
ideally verify incompatible flags in the frontend(s).
Original comment by tetra2...@gmail.com
on 10 Mar 2015 at 4:40
>> do you have a complete list?
No, z,defs is the only one we hit periodically.
http://clang.llvm.org/docs/AddressSanitizer.html mentions it.
(we have too much documentation, sadly)
Original comment by konstant...@gmail.com
on 13 Mar 2015 at 10:07
Adding Project:AddressSanitizer as part of GitHub migration.
Original comment by ramosian.glider@gmail.com
on 30 Jul 2015 at 9:06
Original issue reported on code.google.com by
xiaoyur...@gmail.com
on 9 Mar 2015 at 7:44Attachments: