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.

Uros.

>
>
> --
> H.J.

Reply via email to