Hi,

As Kee’s requested in this PR: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101891

=====

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

=======

This patch switch all MOV to XOR on i386.

Bootstrapped and regresstion tested on x86_64-linux-gnu. 

Okay for gcc13? 

Thanks.

Qing

==========================================

Attachment: 0001-change-mov-to-xor-fix-all-testing-cases.patch
Description: 0001-change-mov-to-xor-fix-all-testing-cases.patch

Reply via email to