]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: fix gcc/libasan.so load order
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 9 Oct 2024 15:26:25 +0000 (16:26 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 17 Oct 2024 13:35:10 +0000 (08:35 -0500)
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>
scripts/test-wrapper.sh

index 78b48324b824f326273faf9ab99f3dce01128bd8..073446f1a6daf5d77d1f417341e76e072647f431 100755 (executable)
@@ -3,8 +3,14 @@
 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 "$@"