I am trying to use AddressSanitizer on Raspbian.
I use the following to compile my program:
gcc -fsanitize=address -fno-omit-frame-pointer -g prog.c -o prog
Even for the simplest program (just a Hello World), I get the following when trying to run it:
==1966==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
While I can work around this using the -static-libasan compilation flag, I would like to understand why this happens on Raspbian, but not on other platforms. I do not see the same on x86_64 Ubuntu 16.04 or 19.04.
What exactly is different in Raspbian that causes this?
I was hoping to be able to compile and run programs in a uniform way on multiple platforms (including x86_64 Linux and macOS, even in debug mode with AddressSanitizer). Some platforms may require special flags, but I would like to understand how to correctly detect that.