From dabf2dc7baed08d284144b64eb1f0e9bee386361 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 21 Apr 2025 19:19:12 +0800 Subject: [PATCH] [Compiler-RT][HWASAN] Support when hwasan detect error do not abort. Signed-off-by: Eric --- compiler-rt/lib/hwasan/hwasan.cpp | 7 ++++++- .../lib/hwasan/hwasan_tag_mismatch_aarch64.S | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp index 652ed075150a..ed6451c4712e 100644 --- a/compiler-rt/lib/hwasan/hwasan.cpp +++ b/compiler-rt/lib/hwasan/hwasan.cpp @@ -250,7 +250,12 @@ void HwasanTagMismatch(uptr addr, uptr access_info, uptr *registers_frame, HandleTagMismatch(ai, (uptr)__builtin_return_address(0), (uptr)__builtin_frame_address(0), nullptr, registers_frame); - __builtin_unreachable(); + // OHOS_LOCAL begin + bool fatal = flags()->halt_on_error || !ai.recover; + if (fatal) { + __builtin_unreachable(); + } + // OHOS_LOCAL end } Thread *GetCurrentThread() { diff --git a/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S b/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S index bcb0df420190..c5df776c6e7b 100644 --- a/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S +++ b/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S @@ -145,6 +145,25 @@ __hwasan_tag_mismatch_v2: mov x2, sp bl __hwasan_tag_mismatch4 + // OHOS_LOCAL begin + ldp x2, x3, [sp, #16] + ldp x4, x5, [sp, #32] + ldp x6, x7, [sp, #48] + ldp x8, x9, [sp, #64] + ldp x10, x11, [sp, #80] + ldp x12, x13, [sp, #96] + ldp x14, x15, [sp, #112] + ldp x16, x17, [sp, #128] + ldp x18, x19, [sp, #144] + ldp x20, x21, [sp, #160] + ldp x22, x23, [sp, #176] + ldp x24, x25, [sp, #192] + ldp x26, x27, [sp, #208] + ldr x28, [sp, #224] + ldp x29, x30, [sp, #232] + ldp x0, x1, [sp], #256 + ret + // OHOS_LOCAL end CFI_ENDPROC .Lfunc_end0: -- Gitee