-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Use the thread local stack protector for Android targets #87672
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
[RISCV] Use the thread local stack protector for Android targets #87672
Conversation
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
@llvm/pr-subscribers-backend-risc-v Author: Paul Kirth (ilovepi) ChangesAndroid supports per thread stack protectors that are individually managed and Full diff: https://github.com/llvm/llvm-project/pull/87672.diff 1 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 279d8a435a04ca..5bd96d5e2c403c 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -20657,6 +20657,12 @@ Value *RISCVTargetLowering::getIRStackGuard(IRBuilderBase &IRB) const {
if (Subtarget.isTargetFuchsia())
return useTpOffset(IRB, -0x10);
+ // Android provides a fixed TLS slot for the stack cookie. See the definition
+ // of TLS_SLOT_STACK_GUARD in
+ // https://android.googlesource.com/platform/bionic/+/master/libc/platform/bionic/tls_defines.h
+ if (Subtarget.isTargetAndroid())
+ return useTpOffset(IRB, -0x18);
+
return TargetLowering::getIRStackGuard(IRB);
}
|
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/master/main/ in the url to get the current version. (master "works" but it's frozen in time; main will track future changes.)
otherwise lgtm...
Probably someone should update AArch64 which has the same comment? |
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Done in #87726 |
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
I plan to land this today, after presubmits are green. |
Android supports per thread stack protectors that are individually managed and
initialized, which can provide stronger protections than using the global stack
protector cookie. This patch matches the convention for other architectures
targeting Android platforms.