Skip to content

Commit 81bcc21

Browse files
committed
Arm backend: Add support for asan in executor_runner
A lightweight AddressSanitizer runtime tailored for the ExecuTorch bare metal examples. The goal is to provide basic memory safety diagnostics while keeping the runtime self-contained. This uses the kernel asan so it is not full asan. Signed-off-by: per.held@arm.com Change-Id: I7ca5a6d39450b13ed461f0d1b91e1f17ab69a42e
1 parent a93f59e commit 81bcc21

File tree

9 files changed

+556
-4
lines changed

9 files changed

+556
-4
lines changed

backends/arm/scripts/build_executorch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# LICENSE file in the root directory of this source tree.
66

77
# Optional parameter:
8-
# --build_type= "Release" | "Debug" | "RelWithDebInfo" | "UndefinedSanitizer"
8+
# --build_type= "Release" | "Debug" | "RelWithDebInfo" | "UndefinedSanitizer" | "AddressSanitizer"
99
# --etdump build with devtools-etdump support
1010

1111
set -eu
@@ -28,7 +28,7 @@ help() {
2828
echo "Usage: $(basename $0) [options]"
2929
echo "Options:"
3030
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
31-
echo " --build_type=<TYPE> Build with Release, Debug, RelWithDebInfo or UndefinedSanitizer, default is ${build_type}"
31+
echo " --build_type=<TYPE> Build with Release, Debug, RelWithDebInfo, UndefinedSanitizer or AddressSanitizer, default is ${build_type}"
3232
echo " --devtools Build Devtools libs"
3333
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
3434
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc Default: ${toolchain}"

backends/arm/test/test_arm_baremetal.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,15 @@ test_undefinedbehavior_sanitizer() {
404404
echo "${TEST_SUITE_NAME}: PASS"
405405
}
406406

407+
test_address_sanitizer() {
408+
echo "${TEST_SUITE_NAME}: Test ethos-u executor_runner with ASAN"
409+
410+
mkdir -p arm_test/test_run
411+
# Ethos-U85
412+
echo "${TEST_SUITE_NAME}: Test target Ethos-U85"
413+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u85-128 --model_name=examples/arm/example_modules/add.py --build_type=AddressSanitizer
414+
echo "${TEST_SUITE_NAME}: PASS"
415+
}
416+
417+
407418
${TEST_SUITE}

examples/arm/asan/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
add_library(executorch_asan STATIC asan_runtime.c)
7+
8+
target_compile_features(executorch_asan PRIVATE c_std_11)
9+
10+
target_compile_options(
11+
executorch_asan PRIVATE -fno-sanitize=address -fno-sanitize=kernel-address
12+
-fno-sanitize=undefined
13+
)
14+
15+
set_target_properties(executorch_asan PROPERTIES OUTPUT_NAME "asan")
16+
17+
install(
18+
TARGETS executorch_asan
19+
EXPORT ExecuTorchTargets
20+
ARCHIVE DESTINATION lib
21+
)

0 commit comments

Comments
 (0)