> On Aug 24, 2020, at 3:26 PM, Segher Boessenkool <seg...@kernel.crashing.org> 
> wrote:
> 
> On Mon, Aug 24, 2020 at 01:48:02PM -0500, Qing Zhao wrote:
>> 
>> 
>>> On Aug 24, 2020, at 12:59 PM, Segher Boessenkool 
>>> <seg...@kernel.crashing.org> wrote:
>>> 
>>> [ Please quote correctly.  I fixed this up a bit. ]
>>> 
>>> On Mon, Aug 24, 2020 at 02:47:22PM +0000, Rodriguez Bahena, Victor wrote:
>>>>> The call-clobbered regs are the only ones you *can* touch.  That does
>>>>> not mean you should clear them all (it doesn't help much at all in some
>>>>> cases).  Only the backend knows.
>>>> 
>>>> I think that for ROP mitigation purpose, we only need to clear the 
>>>> call-used (i.e, call-clobbered) registers that are used in the current 
>>>> routine and
>>>> can pass parameters.
>>> 
>>> Which is more than you *can* do as well (consider return value registers
>>> for example; there are more cases, in general; only the backend code can
>>> know what is safe to do).
>> 
>> Yes, So, we agreed to move the code generation implementation part into 
>> backend.
>> 
>> In Middle-end, we will only compute the hard register set based on call abi 
>> information and data flow information, also handle the command line option.
> 
> You cannot in general figure out what registers you can clobber without
> asking the backend.  You can figure out some that you *cannot* clobber,
> but that isn't very useful.
> 
> Do you want to do this before or after the epilogue code is generated?

static rtx_insn *
make_epilogue_seq (void)
{
  if (!targetm.have_epilogue ())
    return NULL;

  start_sequence ();
  emit_note (NOTE_INSN_EPILOGUE_BEG);

 +++++ gen_call_used_regs_seq ();                     // this is the place to 
emit the zeroing insn sequence

  rtx_insn *seq = targetm.gen_epilogue ();
…
}

Any comment on this?

thanks.

Qing




> 
> 
> Segher

Reply via email to