gcc parity: -fstack-clash-protection isn't implemented in clang
source link: https://bugs.llvm.org/show_bug.cgi?id=40802
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Bugzilla – Bug 40802
gcc parity: -fstack-clash-protection isn't implemented in clang
Last modified: 2020-08-28 16:48:02 PDT
New user self-registration is disabled due to spam. For an account please email [email protected] with your e-mail address and full name.
Bug 40802 - gcc parity: -fstack-clash-protection isn't implemented in clang
Reported: 2019-02-21 06:12 PST by Sylvestre Ledru
Modified: 2020-08-28 16:48 PDT (History) CC List: 8 users (show)
Attachments Add an attachment (proposed patch, testcase, etc.)
This isn't really hard to do. On all Windows targets, we actually do something similar already, due to the stack guard page rules. But it depends on the platform providing a function __chkstk, which generally doesn't exist on non-Windows platforms, so maybe not the best approach. We can provide it in compiler-rt, but not all users link against compiler-rt. (We actually have an IR attribute "probe-stack" to force code to be generated like this, but I think that only currently works on x86. IIRC Rust uses this.) Glancing at the backend code, we actually have code to emit the appropriate inline loop already on x86-64... see https://reviews.llvm.org/rL252578. But we only use that in the "CoreCLR" environment (not sure what that is off the top of my head). I guess we can use that code as a starting point.
For the record: https://reviews.llvm.org/D68720 implements that for x86
Can the x86 implementation be generalized to add support to aarch64 and riscv?
Stack allocation/layout is fundamentally target-specific, so we need to generate target-specific instruction sequences to actually probe the stack. So the logic mostly can't be shared; each target needs to check for the presence of the probe-stack attribute in LLVM IR, and generate the appropriate instruction sequence.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK