Fix the LD_PRELOAD path to libasan in the 'run' command 55/144955/2
authorDmitriy Nikiforov <d.nikiforov@partner.samsung.com>
Fri, 18 Aug 2017 12:17:35 +0000 (15:17 +0300)
committerDmitriy Nikiforov <d.nikiforov@partner.samsung.com>
Tue, 22 Aug 2017 09:20:40 +0000 (12:20 +0300)
Now it uses libasan.so from the system /usr/lib[64] directory.

Change-Id: I9f13f0674bca61258bf0983fad68b0b0a344e756

infra/commands/run.sh

index 63e3173..b5f1f7f 100755 (executable)
@@ -56,8 +56,8 @@ declare -A LIBFUZZER_COV_OPTS=([close_fd_mask]=3
                                [dump_coverage]=1
                                [runs]=0)
 
-declare -A LIB_DIRS=([x86_64]="/sanitized/usr/lib64"
-                     [i686]="/sanitized/usr/lib")
+declare -A LIB_DIRS=([x86_64]="usr/lib64"
+                     [i686]="usr/lib")
 
 ########################################################
 #               GLOBAL OPTIONS PARSING
@@ -112,7 +112,7 @@ ASAN_OPTS[log_path]="${logs_dir}/asan.log"
 
 # get the sanitized libraries directory (used in LD_PRELOAD and LD_LIBRARY_PATH)
 arch=$(sdb_shell_verbose uname -m)
-lib_dir=${LIB_DIRS[$arch]}
+lib_dir="/sanitized/${LIB_DIRS[$arch]}"
 
 # parse .options file if it exists
 options=$(sdb_shell_verbose "[[ -f ${options_file} ]] && cat ${options_file} || true")
@@ -166,7 +166,7 @@ fi
 echo "ASAN_OPTIONS=${asan_opts_str}"
 echo "LIBFUZZER_OPTIONS='${libfuzzer_opts_arr[*]}'"
 echo "LD_LIBRARY_PATH=${lib_dir}"
-echo "LD_PRELOAD=${lib_dir}/libasan.so"
+echo "LD_PRELOAD=/${LIB_DIRS[$arch]}/libasan.so"
 
 if (( DUMP_COVERAGE == 1 )); then
     exec_dir="${coverage_dir}"
@@ -183,7 +183,7 @@ echo "${SDB_CMD} ${target_bin} \${LIBFUZZER_OPTIONS} ${generated_corpus_dir} ${s
 ${SDB_CMD} shell cd "${exec_dir}" '&&' \
               export "ASAN_OPTIONS=${asan_opts_str}" '&&' \
               export "LD_LIBRARY_PATH=${lib_dir}" '&&' \
-              export "LD_PRELOAD=${lib_dir}/libasan.so" '&&' \
+              export "LD_PRELOAD=/${LIB_DIRS[$arch]}/libasan.so" '&&' \
               "${target_bin}" "${libfuzzer_opts_arr[@]}" "${generated_corpus_dir}" "${seed_corpus_dir}"
 
 # print ASan logs if any