[PATCH] D48836: [cfi-verify] Support AArch64.

Joel Galenson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 09:19:39 PDT 2018


jgalenson created this revision.
jgalenson added reviewers: vlad.tsyrklevich, hctim.
Herald added a reviewer: javed.absar.
Herald added subscribers: llvm-commits, kristof.beyls.

This patch adds support for AArch64 to cfi-verify.

      

This required three changes to cfi-verify.  First, instead of searching for an instruction called TRAP (which the X86 instruction is named), it also searches for BRK (the name of the AArch64 instruction).  Generalizing this would be cleaner but have much larger scope, so I left it this way for now, although we can discuss if we'd prefer doing it the other way.

Second, the code that ensures that the operand register is not clobbered between the CFI check and the indirect call needs to allow a single dereference (in X86 this happens as part of the jump instruction, but not in AArch64).  So I modified the code to walk backwards from the indirect call and look for multiple loads.

Third, we needed to ensure that return instructions are not counted as indirect branches.  Technically, returns are indirect branches and can be covered by CFI, but LLVM's forward-edge CFI does not protect them, and X86 does not consider them, so we keep that behavior (this might also be worth discussing, however).

      

In addition, we had to improve AArch64's code to evaluate the branch target of a MCInst to handle calls where the destination is not the first operand (which it often is not).


Repository:
  rL LLVM

https://reviews.llvm.org/D48836

Files:
  lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
  test/tools/llvm-cfi-verify/AArch64/tiny.s
  tools/llvm-cfi-verify/lib/FileAnalysis.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48836.153733.patch
Type: text/x-patch
Size: 8160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/91170385/attachment.bin>


More information about the llvm-commits mailing list