On Wed, Feb 12, 2020 at 1:21 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> On Mon, Feb 10, 2020 at 12:01 PM Uros Bizjak <ubiz...@gmail.com> wrote:
> >
> > On Mon, Feb 10, 2020 at 8:53 PM H.J. Lu <hjl.to...@gmail.com> wrote:
> > >
> > > On Mon, Feb 10, 2020 at 11:40 AM Uros Bizjak <ubiz...@gmail.com> wrote:
> > > >
> > > > On Mon, Feb 10, 2020 at 8:22 PM H.J. Lu <hjl.to...@gmail.com> wrote:
> > > > >
> > > > > Since nested function isn't only called directly, there is ENDBR32 at
> > > > > function entry and we need to skip it for direct jump in trampoline.
> > > >
> > > > Hm, I'm afraid I don't understand this comment. Can you perhaps 
> > > > rephrase it?
> > > >
> > >
> > > ix86_trampoline_init has
> > >
> > >      /* Compute offset from the end of the jmp to the target function.
> > >          In the case in which the trampoline stores the static chain on
> > >          the stack, we need to skip the first insn which pushes the
> > >          (call-saved) register static chain; this push is 1 byte.  */
> > >       offset += 5;
> > >       disp = expand_binop (SImode, sub_optab, fnaddr,
> > >                            plus_constant (Pmode, XEXP (m_tramp, 0),
> > >                                           offset - (MEM_P (chain) ? 1 : 
> > > 0)),
> > >                            NULL_RTX, 1, OPTAB_DIRECT);
> > >       emit_move_insn (mem, disp);
> > >
> > > Without CET, we got
> > >
> > > 0000011 <bar.1878>:
> > >   11: 56                    push   %esi
> > >   12: 55                    push   %ebp   <<<<<< trampoline jumps here.
> > >   13: 89 e5                mov    %esp,%ebp
> > >   15: 83 ec 08              sub    $0x8,%esp
> > >
> > > With CET, if bar isn't only called directly, we got
> > >
> > > 00000015 <bar.1878>:
> > >   15: f3 0f 1e fb          endbr32
> > >   19: 56                    push   %esi
> > >   1a: 55                    push   %ebp   <<<<<<<< trampoline jumps here.
> > >   1b: 89 e5                mov    %esp,%ebp
> > >   1d: 83 ec 08              sub    $0x8,%esp
> > >
> > > We need to add 4 bytes for trampoline to skip endbr32.
> > >
> > > Here is the updated patch to check if nested function isn't only
> > > called directly,
> >
> > Please figure out the final patch. I don't want to waste my time
> > reviewing different version every half hour. Ping me in a couple of
> > days.
>
> This is the final version:
>
> https://gcc.gnu.org/ml/gcc-patches/2020-02/msg00586.html
>
> You can try the testcase in the patch on any machine with CET binutils
> since ENDBR32 is nop on none-CET machines.  Without this patch,
> the test will fail.

Please rephrase the comment. I don't understand what it tries to say.

Uros.

Reply via email to