[PATCH] D154911: Enabling fstack_clash_protection for arm32 bit, thumb and thumb2 mode

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 26 10:58:25 PDT 2023


efriedma added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3460
+  } else if (EffectiveTriple.isArm() || EffectiveTriple.isThumb()) {
+    CmdArgs.push_back("-mstack-probe-size=1024");
+  }
----------------
tnfchris wrote:
> efriedma wrote:
> > Why 1024?
> 1024 was experimentally determined by Arm and is part of the ABI for stack clash (which has not yet been published).  It was determined by examining a large number of programs and looking at the function stack usages.  1024 covers 80-90% of programs such that we can minimize the number of probes required in the average cases. 
There are actually multiple numbers involved here, no?  One is the spacing of probes, i.e. if allocating a large amount of stack, how many times you need to probe; this is basically the page size of the target. the other is how much unprobed space a function is allowed to allocate before calling another function. Referring to the the AArch64 patch, -mstack-probe-size is the former, the hardcoded "1024" is the latter.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154911/new/

https://reviews.llvm.org/D154911



More information about the cfe-commits mailing list