llvm-project/llvm/tools/llvm-cfi-verify
Joel Galenson 6cc0e63e2f [cfi-verify] Support cross-DSO
When used in cross-DSO mode, CFI will generate calls to special functions rather than trap instructions.  For example, instead of generating

if (!InlinedFastCheck(f))
  abort();
call *f

CFI generates

if (!InlinedFastCheck(f))
  __cfi_slowpath(CallSiteTypeId, f);
call *f

This patch teaches cfi-verify to recognize calls to __cfi_slowpath and abort and treat them as trap functions.

In addition to normal symbols, we also parse the dynamic relocations to handle cross-DSO calls in libraries.

We also extend cfi-verify to recognize other patterns that occur using cross-DSO.  For example, some indirect calls are not guarded by a branch to a trap but instead follow a call to __cfi_slowpath.  For example:

if (!InlinedFastCheck(f))
  call *f
else {
  __cfi_slowpath(CallSiteTypeId, f);
  call *f
}

In this case, the second call to f is not marked as protected by the current code.  We thus recognize if indirect calls directly follow a call to a function that will trap on CFI violations and treat them as protected.

We also ignore indirect calls in the PLT, since on AArch64 each entry contains an indirect call that should not be protected by CFI, and these are labeled incorrectly when debug information is not present.

Differential Revision: https://reviews.llvm.org/D49383

llvm-svn: 340612
2018-08-24 15:21:58 +00:00
..
lib [cfi-verify] Support cross-DSO 2018-08-24 15:21:58 +00:00
CMakeLists.txt Make llvm-cfi-verify CMakeLists.txt formatting more consistent with the rest of LLVM. 2018-05-09 01:07:02 +00:00
LLVMBuild.txt [cfi-verify] Add blacklist parsing for result filtering. 2017-11-03 20:54:26 +00:00
llvm-cfi-verify.cpp Fix broken builds due to mismatched min/max types 2018-02-02 00:07:14 +00:00