[PATCH] D31112: Proposal: Backward-edge CFI for return statements (RCFI)

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 00:04:50 PDT 2017


On Wed, Mar 22, 2017 at 12:29 AM, Kostya Serebryany via Phabricator
via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> kcc added a comment.
>
>>> But I foresee that as being difficult
>
> Yep. That pesky phase-ordering again.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D31112


FWIW another option for general case that may be faster.

We emit a unique hash after each call instruction:

  call <foo>
  nop $0x12345678 // can use nop disp

The hash is associated with the callee. Callee checks that there is a
correct hash at the return site:

<foo>:
  ...
  mov 8(%rsp), %r8
  cmpd 2(%r8), $0x12345678
  jne bad
  ret

Can also use pop+jmp, not sure if it's faster:

<foo>:
  ...
  pop %r8
  cmpd 2(%r8), $0x12345678
  jne bad
  jmp %r8


More information about the llvm-commits mailing list