https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101891

            Bug ID: 101891
           Summary: Adjust -fzero-call-used-regs to always use XOR
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kees at outflux dot net
  Target Milestone: ---

Currently -fzero-call-used-regs will use a pattern of:

XOR regA,regA
MOV regA,regB
MOV regA,regC
...
RET

However, this introduces both a register ordering dependency (e.g. the CPU
cannot clear regB without clearing regA first), and while greatly reduces
available ROP gadgets, it does technically leave a set of "MOV" ROP gadgets at
the end of functions (e.g. "MOV regA,regC; RET").

Please switch to always using XOR:

XOR regA,regA
XOR regB,regB
XOR regC,regC
...
RET

Reply via email to