On 11/14/24 9:14 PM, Kito Cheng wrote:
AddressSanitizer has supported dynamic shadow offsets since 2016[1], but
GCC hasn't implemented this yet because targets using dynamic shadow
offsets, such as Fuchsia and iOS, are mostly unsupported in GCC.

However, RISC-V 64 switched to dynamic shadow offsets this year[2] because
virtual memory space support varies across different RISC-V cores, such as
Sv39, Sv48, and Sv57. We realized that the best way to handle this
situation is by using a dynamic shadow offset to obtain the offset at
runtime.

We introduce a new target hook, TARGET_ASAN_DYNAMIC_SHADOW_OFFSET_P, to
determine if the target is using a dynamic shadow offset, so this change
won't affect the static offset path. Additionally, TARGET_ASAN_SHADOW_OFFSET
continues to work even if TARGET_ASAN_DYNAMIC_SHADOW_OFFSET_P is non-zero,
ensuring that KASAN functions as expected.

This patch set has been verified on the Banana Pi F3, currently one of the
most popular RISC-V development boards. All AddressSanitizer-related tests
passed without introducing new regressions.

It was also verified on AArch64 and x86_64 with no regressions in
AddressSanitizer.

[1] 
https://github.com/llvm/llvm-project/commit/130a190bf08a3d955d9db24dac936159dc049e12
[2] 
https://github.com/llvm/llvm-project/commit/da0c8b275564f814a53a5c19497669ae2d99538d
---
  gcc/asan.cc               | 80 ++++++++++++++++++++++++++++++++++++---
  gcc/asan.h                |  3 ++
  gcc/config/riscv/riscv.cc |  3 ++
  gcc/doc/tm.texi           |  6 ++-
  gcc/doc/tm.texi.in        |  2 +
  gcc/sanopt.cc             |  4 ++
  gcc/target.def            |  8 +++-
  gcc/toplev.cc             |  3 +-
  8 files changed, 101 insertions(+), 8 deletions(-)
Needs a ChangeLog.  New functions should have function comments.

OK with those changes if nobody has objected in 48hrs.

Thanks,
jeff

Reply via email to