This is an example of ASAN usage for sanitizing of shared library code. The following cases are considered:
- Library is compiled without sanitizer, while binary is compiled with sanitizer;
- Library and binary are compiled with sanitizer;
- Library is compiled with sanitizer, while binary is compiled without sanitizer.
In this case sanitizer doesn't find the error.
- make lib-gcc && make bin-gcc-ldynamic
- make lib-gcc && make bin-gcc-lstatic (output presented)
- make lib-gcc && make bin-clang-ldynamic
- make lib-gcc && make bin-clang-lstatic
In this case sanitizer works well.
- make lib-gcc-asan && make bin-gcc-ldynamic
- make lib-gcc-asan && make bin-gcc-lstatic (output presented)
- make lib-clang-asan && make bin-clang-ldynamic
- make lib-clang-asan && make bin-clang-lstatic
- make lib-gcc-asan && make bin-gcc-stat-lstatic
In this case sanitizer alswo works well.
- make lib-gcc-asan && make bin-gcc-preload (output presented)
Motivated by this gist.