Closed nickdesaulniers closed 2 years ago
mentioned in issue llvm/llvm-bugzilla-archive#49902
mentioned in issue llvm/llvm-project#4440
This feature exists in GCC since version 11:
-fzero-call-used-regs=[skip|used-gpr|all-gpr|used|all]
The kernel supports the use of =used-gpr since v5.15 as CONFIG_ZERO_CALL_USED_REGS:
Bug llvm/llvm-bugzilla-archive#49902 has been marked as a duplicate of this bug.
Here's a better link: https://gcc.gnu.org/legacy-ml/gcc-patches/2018-10/msg02079.html
initial support for this will ship for x86_64 in clang-15. We'll pursue enabling more backends, but it's a fair amount of work per arch to get this working. Should be easier now that clang supports the flags and some support is arch agnostic.
https://reviews.llvm.org/rGdeaf22bc0e306bc44c70d2503e9364b5ed312c49
Extended Description
GCC has added ways of specifying that certain registers should be zero'd upon function return. I believe this is to help cut down on gadgets used in ROP chains. Is this something that could be added in Clang?
https://github.com/clearlinux-pkgs/gcc/blob/master/zero-regs-gcc8.patch