xref: /aosp_15_r20/external/vboot_reference/scripts/image_signing/ensure_not_ASAN.sh (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1#!/bin/bash
2
3# Copyright 2011 The ChromiumOS Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Abort on error.
8set -e
9
10# Load common constants and variables.
11. "$(dirname "$0")/common.sh"
12
13usage() {
14  echo "Usage $PROG image"
15}
16
17main() {
18  if [[ $# -ne 1 ]]; then
19    usage
20    exit 1
21  fi
22
23  local image="$1"
24
25  local loopdev rootfs
26  if [[ -d "${image}" ]]; then
27    rootfs="${image}"
28  else
29    rootfs=$(make_temp_dir)
30    loopdev=$(loopback_partscan "${image}")
31    mount_loop_image_partition_ro "${loopdev}" 3 "${rootfs}"
32  fi
33
34  # This mirrors the check performed in the platform_ToolchainOptions
35  # autotest.
36  if readelf -s "$rootfs/opt/google/chrome/chrome" | \
37     grep -q __asan_init; then
38    exit 1
39  fi
40}
41main "$@"
42