Index: gcc/config/riscv/riscv.c =================================================================== --- gcc/config/riscv/riscv.c +++ gcc/config/riscv/riscv.c @@ -5292,6 +5292,14 @@ return true; } +/* Implement TARGET_ASAN_SHADOW_OFFSET. */ + +static unsigned HOST_WIDE_INT +riscv_asan_shadow_offset (void) +{ + return HOST_WIDE_INT_1U << 36; +} + /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" @@ -5475,6 +5483,9 @@ #undef TARGET_NEW_ADDRESS_PROFITABLE_P #define TARGET_NEW_ADDRESS_PROFITABLE_P riscv_new_address_profitable_p +#undef TARGET_ASAN_SHADOW_OFFSET +#define TARGET_ASAN_SHADOW_OFFSET riscv_asan_shadow_offset + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-riscv.h" Index: libsanitizer/sanitizer_common/sanitizer_common.h =================================================================== --- libsanitizer/sanitizer_common/sanitizer_common.h +++ libsanitizer/sanitizer_common/sanitizer_common.h @@ -649,7 +649,8 @@ kModuleArchARMV7, kModuleArchARMV7S, kModuleArchARMV7K, - kModuleArchARM64 + kModuleArchARM64, + kModuleArchRISCV }; // Opens the file 'file_name" and reads up to 'max_len' bytes. @@ -672,7 +673,7 @@ error_t *errno_p = nullptr); // When adding a new architecture, don't forget to also update -// script/asan_symbolize.py and sanitizer_symbolizer_libcdep.cpp. +// sanitizer_symbolizer_libcdep.cpp. inline const char *ModuleArchToString(ModuleArch arch) { switch (arch) { case kModuleArchUnknown: @@ -693,6 +694,8 @@ return "armv7k"; case kModuleArchARM64: return "arm64"; + case kModuleArchRISCV; + return "riscv"; } CHECK(0 && "Invalid module arch"); return ""; Index: libsanitizer/sanitizer_common/sanitizer_platform.h =================================================================== --- libsanitizer/sanitizer_common/sanitizer_platform.h +++ libsanitizer/sanitizer_common/sanitizer_platform.h @@ -213,6 +213,14 @@ # define SANITIZER_MYRIAD2 0 #endif + +#if defined(__riscv__) +# define SANITIZER_RISCV 1 +#else +# define SANITIZER_RISCV 0 +#endif + + // By default we allow to use SizeClassAllocator64 on 64-bit platform. // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 // does not work well and we need to fallback to SizeClassAllocator32. Index: libsanitizer/sanitizer_common/sanitizer_symbolizer_libcdep.cpp =================================================================== --- libsanitizer/sanitizer_common/sanitizer_symbolizer_libcdep.cpp +++ libsanitizer/sanitizer_common/sanitizer_symbolizer_libcdep.cpp @@ -249,7 +249,7 @@ } // When adding a new architecture, don't forget to also update - // script/asan_symbolize.py and sanitizer_common.h. + // sanitizer_common.h. void GetArgV(const char *path_to_binary, const char *(&argv)[kArgVMax]) const override { #if defined(__x86_64h__) @@ -270,6 +270,8 @@ const char* const kSymbolizerArch = "--default-arch=s390x"; #elif defined(__s390__) const char* const kSymbolizerArch = "--default-arch=s390"; +#elif defined(__riscv__) + const char* const kSymbolizerArch = "--default-arch=riscv"; #else const char* const kSymbolizerArch = "--default-arch=unknown"; #endif