Currently we silence the ordering warning from libasan, via the
environment: ASAN_OPTIONS=verify_asan_link_order=0...
Instead we should be LD_PRELOAD-ing the library, since otherwise we
might end with miss-matched symbols - one coming from libasan, with the
counter part from the system library.
Plus LD_PRELOAD is the only way to make the clang sanitizers work...
That I have found. Although that's coming with a later patch.
v2:
- handle when the file is a script
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/179
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
set -euo pipefail
if [[ ${ASAN_OPTIONS-} || ${UBSAN_OPTIONS-} || ${MSAN_OPTIONS-} ]]; then
- ASAN_OPTIONS=verify_asan_link_order=0:halt_on_error=1:abort_on_error=1:print_summary=1
- export ASAN_OPTIONS
+ LD_PRELOAD=$(gcc -print-file-name=libasan.so)
+ # In some cases, like in Fedora, the file is a script which cannot be
+ # preloaded. Attempt to extract the details from within.
+ if grep -q INPUT "$LD_PRELOAD"; then
+ input=$(sed -r -n "s/INPUT \( (.*) \)/\1/p" "$LD_PRELOAD")
+ test -f "$input" && LD_PRELOAD="$input"
+ fi
+ export LD_PRELOAD
fi
exec "$@"