[all-commits] [llvm/llvm-project] d157a9: Add Windows Control Flow Guard checks (/guard:cf).

Andrew Paverd via All-commits all-commits at lists.llvm.org
Mon Oct 28 08:20:03 PDT 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d157a9bc8ba1085cc4808c6941412322a7fd884e
      https://github.com/llvm/llvm-project/commit/d157a9bc8ba1085cc4808c6941412322a7fd884e
  Author: Andrew Paverd <andrew.paverd at microsoft.com>
  Date:   2019-10-28 (Mon, 28 Oct 2019)

  Changed paths:
    M clang/docs/ClangCommandLineReference.rst
    M clang/include/clang/Basic/CodeGenOptions.def
    M clang/include/clang/Driver/CC1Options.td
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/MSVC.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/test/CodeGen/cfguardtable.c
    M clang/test/Driver/cl-fallback.c
    M clang/test/Driver/cl-options.c
    M llvm/docs/LangRef.rst
    M llvm/docs/ReleaseNotes.rst
    M llvm/include/llvm/CodeGen/MachineFunction.h
    M llvm/include/llvm/CodeGen/Passes.h
    M llvm/include/llvm/CodeGen/TargetCallingConv.h
    M llvm/include/llvm/CodeGen/TargetLowering.h
    M llvm/include/llvm/IR/CallingConv.h
    M llvm/include/llvm/IR/InstrTypes.h
    M llvm/include/llvm/IR/LLVMContext.h
    M llvm/include/llvm/InitializePasses.h
    M llvm/include/llvm/MC/MCObjectFileInfo.h
    M llvm/include/llvm/Target/TargetCallingConv.td
    A llvm/include/llvm/Transforms/CFGuard.h
    M llvm/lib/AsmParser/LLLexer.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/AsmParser/LLToken.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
    M llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h
    A llvm/lib/CodeGen/CFGuardLongjmp.cpp
    M llvm/lib/CodeGen/CMakeLists.txt
    M llvm/lib/CodeGen/CodeGen.cpp
    M llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
    M llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/LLVMContext.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/MC/MCObjectFileInfo.cpp
    M llvm/lib/Target/AArch64/AArch64CallingConvention.h
    M llvm/lib/Target/AArch64/AArch64CallingConvention.td
    M llvm/lib/Target/AArch64/AArch64FastISel.cpp
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
    M llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
    M llvm/lib/Target/AArch64/LLVMBuild.txt
    M llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
    M llvm/lib/Target/ARM/ARMCallingConv.h
    M llvm/lib/Target/ARM/ARMCallingConv.td
    M llvm/lib/Target/ARM/ARMFastISel.cpp
    M llvm/lib/Target/ARM/ARMISelLowering.cpp
    M llvm/lib/Target/ARM/ARMTargetMachine.cpp
    M llvm/lib/Target/ARM/LLVMBuild.txt
    M llvm/lib/Target/X86/LLVMBuild.txt
    M llvm/lib/Target/X86/X86AsmPrinter.cpp
    M llvm/lib/Target/X86/X86CallingConv.td
    M llvm/lib/Target/X86/X86FastISel.cpp
    M llvm/lib/Target/X86/X86RegisterInfo.cpp
    M llvm/lib/Target/X86/X86TargetMachine.cpp
    A llvm/lib/Transforms/CFGuard/CFGuard.cpp
    A llvm/lib/Transforms/CFGuard/CMakeLists.txt
    A llvm/lib/Transforms/CFGuard/LLVMBuild.txt
    M llvm/lib/Transforms/CMakeLists.txt
    M llvm/lib/Transforms/LLVMBuild.txt
    M llvm/test/Bitcode/calling-conventions.3.2.ll
    M llvm/test/Bitcode/calling-conventions.3.2.ll.bc
    M llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
    A llvm/test/CodeGen/AArch64/cfguard-checks.ll
    A llvm/test/CodeGen/AArch64/cfguard-module-flag.ll
    A llvm/test/CodeGen/ARM/cfguard-checks.ll
    A llvm/test/CodeGen/ARM/cfguard-module-flag.ll
    M llvm/test/CodeGen/WinCFGuard/cfguard.ll
    A llvm/test/CodeGen/X86/cfguard-checks.ll
    A llvm/test/CodeGen/X86/cfguard-module-flag.ll
    A llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll
    A llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll

  Log Message:
  -----------
  Add Windows Control Flow Guard checks (/guard:cf).

Summary:
A new function pass (Transforms/CFGuard/CFGuard.cpp) inserts CFGuard checks on
indirect function calls, using either the check mechanism (X86, ARM, AArch64) or
or the dispatch mechanism (X86-64). The check mechanism requires a new calling
convention for the supported targets. The dispatch mechanism adds the target as
an operand bundle, which is processed by SelectionDAG. Another pass
(CodeGen/CFGuardLongjmp.cpp) identifies and emits valid longjmp targets, as
required by /guard:cf. This feature is enabled using the `cfguard` CC1 option.

Reviewers: thakis, rnk, theraven, pcc

Subscribers: ychen, hans, metalcanine, dmajor, tomrittervg, alex, mehdi_amini, mgorny, javed.absar, kristof.beyls, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits

Tags: #clang, #llvm

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




More information about the All-commits mailing list