# Why Asan cannot be static linked? In the Asan FAQ: > Q: I'm getting following error when building my code: gcc: error: cannot specify - > static with -fsanitize=address. > > A: ASan doesn't work with static linkage. You need to disable static linkage in > order to use ASan on your code. This is because Asan "intercepts" many libc funcitons like malloc and free. I.e. Asan has a wrapper for these functions to poison/unpoinson memory regions. The implementation of the intercepters uses `dlsym` to get the addresses of the actual functions and save them. For example, an executable is linked with libc.so. At initialization stage, the sanitizer runtime uses `dlsym` to find the address of `malloc` in libc.so and store it. When `malloc` is called in the executable, the intercepter is exeuted, do some tricks to mark the memory usage, then jump to the actuall `malloc` address recorded earlier. This mechanism only works with dynamic linked. ## Then what's the point of `-static-libasan`? In GCC there is a `-static-libasan` flag; in LLVM it's `-static-libsan`. These flags means to link the runtime library statically, like the initialization process mentioned in above. But it doesn't mean to link everything (libc.so, for example) staticly.