From 6c6888037c8d82228b480eeba0eaf1b0aa83e9f8 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Thu, 21 Jun 2018 08:39:30 +0800 Subject: ec: Make it possible to run tests with AddressSanitizer enabled Automatically use CC=clang if TEST_ASAN is specified. Also, add a __no_sanitize_address attribute macro to prevent ASan from adding guards around host_command, mkbp_event, and hook "arrays" that are generated at link-time. Also, set ASAN_OPTIONS env variable in run_host_test. BRANCH=none BUG=chromium:854924 TEST=make TEST_ASAN=y runtests -j Change-Id: Iaf0ec405022760d757a8a9d62a5022460d1b16e1 Signed-off-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/1109661 Reviewed-by: Vincent Palatin --- include/host_command.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/host_command.h') diff --git a/include/host_command.h b/include/host_command.h index 1f9718fa5f..e68b86c96d 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -248,8 +248,9 @@ void host_packet_receive(struct host_packet *pkt); * Register a host command handler with * commands starting at offset 0x0000 */ -#define DECLARE_HOST_COMMAND(command, routine, version_mask) \ - const struct host_command __keep EXPAND(0x0000, command) \ +#define DECLARE_HOST_COMMAND(command, routine, version_mask) \ + const struct host_command __keep __no_sanitize_address \ + EXPAND(0x0000, command) \ __attribute__((section(".rodata.hcmds."EXPANDSTR(0x0000, command)))) \ = {routine, command, version_mask} @@ -258,7 +259,7 @@ void host_packet_receive(struct host_packet *pkt); * commands starting at offset EC_CMD_BOARD_SPECIFIC_BASE, */ #define DECLARE_PRIVATE_HOST_COMMAND(command, routine, version_mask) \ - const struct host_command __keep \ + const struct host_command __keep __no_sanitize_address \ EXPAND(EC_CMD_BOARD_SPECIFIC_BASE, command) \ __attribute__((section(".rodata.hcmds."\ EXPANDSTR(EC_CMD_BOARD_SPECIFIC_BASE, command)))) \ -- cgit v1.2.1