From 969a5b510e92fc5ef6cd84962448ca9982e290eb Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Sat, 14 Sep 2024 10:46:18 +0800 Subject: [PATCH] compiler.h: AVR 2-byte PC and 3-byte PC do not support returnaddress Compilation error: Kasan/book. c: In the function '__hwasanloaded 16_noabort': Kasan/book. c: 76:5: Warning: 'builtin-turn_dedress' contains only 2 bytes of address kasan_check_report(addr, size, false, return_address(0)); \ ^ Kasan/book. c: 423:1: Note: in expansion of macro 'DEFINE-HWASAN_LOAD-STORE' DEFINE_HWASAN_LOAD_STORE(16) ^ Kasan/book. c: In the function '__hwasan_store16_noabort': Kasan/book. c: 80:5: Warning: 'builtin-turn_dedress' contains only 2 bytes of address kasan_check_report(addr, size, true, return_address(0)); \ ^ Kasan/book. c: 423:1: Note: in expansion of macro 'DEFINE-HWASAN_LOAD-STORE' DEFINE_HWASAN_LOAD_STORE(16) ^ CC: hello. min c hello. min c: In the function 'hello. min': Hello. main. c: 39:3: Warning: 'builtin-turn_dedress' contains only 2 bytes of address printf("Hello, World: %p!!\n", return_address(0)); Signed-off-by: wangmingrong1 --- include/nuttx/compiler.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 2aac80e67a..6f82b6f9f9 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -374,6 +374,15 @@ # undef CONFIG_PTR_IS_NOT_INT # elif defined(__AVR__) + +# if defined(__AVR_2_BYTE_PC__) || defined(__AVR_3_BYTE_PC__) +/* 2-byte 3-byte PC does not support returnaddress */ + +# undef return_address +# define return_address(x) 0 + +# endif + # if defined(CONFIG_AVR_HAS_MEMX_PTR) /* I-space access qualifiers needed by Harvard architecture */