Annotate siglongjmp for HWASan.
HWASan needs to re-tag the newly unallocated stack space to match SP.
Bug: 112438058
Test: SANITIZE_TARGET=hwaddress
Change-Id: I4dddef542d802d63bdea59e32a03425a2c4f870b
diff --git a/libc/arch-arm64/bionic/setjmp.S b/libc/arch-arm64/bionic/setjmp.S
index ee618b1..5e62c28 100644
--- a/libc/arch-arm64/bionic/setjmp.S
+++ b/libc/arch-arm64/bionic/setjmp.S
@@ -191,6 +191,28 @@
bne __bionic_setjmp_checksum_mismatch
#endif
+#if __has_feature(hwaddress_sanitizer)
+ stp x0, x30, [sp, #-16]!
+ .cfi_adjust_cfa_offset 16
+ .cfi_rel_offset x0, 0
+ .cfi_rel_offset x30, 8
+ mov x19, x1 // Save 'value'.
+
+ // load and unmangle destination SP
+ ldr x2, [x0, #(_JB_SIGFLAG * 8)]
+ bic x2, x2, #1
+ ldr x0, [x0, #(_JB_X30_SP * 8 + 8)]
+ eor x0, x0, x2
+ bl __hwasan_handle_longjmp
+
+ mov x1, x19 // Restore 'value'.
+ // Restore original x0 and lr.
+ ldp x0, x30, [sp], #16
+ .cfi_adjust_cfa_offset -16
+ .cfi_restore x0
+ .cfi_restore x30
+#endif
+
// Do we need to restore the signal mask?
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
tbz w2, #0, 1f