Search code examples
address-sanitizer

Is it okay if ASAN runtime loaded as second library?


I want to use ASAN for a process on a system. The system requires another library libfoo to be loaded first. libfoo does not intercept any allocations.

ldd asan_instrumented_proc
    1. linux-vdso.so.1
    2. libfoo
    3. libclang_rt.asan-x86_64.so

I made changes to ASAN to ignore the check on if ASAN is the first linked library.

Do you see any issues with this usage , provided that libfoo does not interfere in asan's functionality ?


Solution

  • Yes, this will work as long as as libfoo does not intercept any function already intercepted by Asan (you can get full list from readelf -sW --dyn-syms $(gcc -print-file-name=libasan.so)). To be safe Asan will emit a warning in that case which you can suppress via ASAN_OPTIONS=verify_asan_link_order=0.