Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asan_static x86-64: Support 64-bit ASAN_SHADOW_OFFSET_CONST redux #76185

Merged
merged 1 commit into from
Dec 25, 2023

Conversation

dankm
Copy link
Contributor

@dankm dankm commented Dec 21, 2023

Similar to b9935bb, but also apply a similar change to ACCESS_CHECK_ADD.

If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch to movabsq and the register offset variant of cmp.

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 21, 2023

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Dan McGregor (dankm)

Changes

Similar to b9935bb, but also apply a similar change to ACCESS_CHECK_ADD.

If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch to movabsq and the register offset variant of cmp.


Full diff: https://github.com/llvm/llvm-project/pull/76185.diff

1 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_rtl_x86_64.S (+5)
diff --git a/compiler-rt/lib/asan/asan_rtl_x86_64.S b/compiler-rt/lib/asan/asan_rtl_x86_64.S
index e44587ac4331c7..3f8800d31ac566 100644
--- a/compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ b/compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -89,7 +89,12 @@ ENDF
 #define ASAN_MEMORY_ACCESS_CHECK_ADD(reg, op, s, c) \
         mov    %##reg,%r10 ;\
         shr    $0x3,%r10 ;\
+        .if ASAN_SHADOW_OFFSET_CONST < 0x80000000  ;\
         ##c    $0x0,ASAN_SHADOW_OFFSET_CONST(%r10) ;\
+        .else                                      ;\
+        movabsq $ASAN_SHADOW_OFFSET_CONST,%r11     ;\
+        ##c    $0x0,(%r10,%r11) ;\
+        .endif                                     ;\
         jne    FLABEL(reg, op, s, add) ;\
         retq  ;\
 

@dankm
Copy link
Contributor Author

dankm commented Dec 21, 2023

I think @MaskRay should probably verify this. I'm not 100% on my x86 assembly.

…vm#75748)

Similar to b9935bb, but also apply a similar change to
ACCESS_CHECK_ADD.

If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch
to `movabsq` and the register offset variant of cmp.
@MaskRay MaskRay merged commit 966d564 into llvm:main Dec 25, 2023
4 checks passed
@dankm dankm deleted the asan-offset branch January 11, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants