On Tue, May 26, 2015 at 3:04 AM, Dmitriy - <[email protected]> wrote: > Hi all. > Inspired by this post > http://tsdgeos.blogspot.ru/2014/03/asan-and-libraries-2nd-part.html > > I wanted to try the following with ASan: > 1) create shared library with error -> libshared.so > 2) create trivial program that used <- libshared.so > > $ ls > main.cpp shared.cpp shared.h > > $ cat main.cpp > #include "shared.h" > > int main(int, char **) > { > Foo f; > return 0; > } > > $ cat shared.cpp > #include "shared.h" > > Foo::Foo() > { > int a[1]; > a[2] = 3; > } > > $ cat shared.h > class Foo > { > public: > Foo(); > }; > > $ clang++ --version > clang version 3.7.0 (trunk 237353) > Target: x86_64-unknown-linux-gnu > Thread model: posix > > $ clang++ -fno-omit-frame-pointer -fsanitize=address -fPIC -g3 -c shared.cpp > $ clang++ -shared -Wl,--no-undefined -o libshared.so -g3 > -lclang_rt.asan-x86_64 -L /usr/local/lib/clang/3.7.0/lib/linux/ shared.o
Why -lclang_rt... ? The usual way is adding -fsanitize=address to both compilation and linking steps. > $ clang++ -fno-omit-frame-pointer -fsanitize=address -lshared -L . -g3 > -Wl,-rpath=/usr/local/lib/clang/3.7.0/lib/linux/ main.cpp > > $ LD_LIBRARY_PATH=. ./a.out > ==14933==Your application is linked against incompatible ASan runtimes. > > What did I do wrong? Please help. > > -- > You received this message because you are subscribed to the Google Groups > "address-sanitizer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "address-sanitizer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
