//===-- CodeGen/AsmPrinter/WinCFGuard.cpp - Control Flow Guard Impl ------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains support for writing the metadata for Windows Control Flow // Guard, including address-taken functions and valid longjmp targets. // //===----------------------------------------------------------------------===// #include "WinCFGuard.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/IR/Constants.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Module.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCStreamer.h" #include <vector> usingnamespacellvm; WinCFGuard::WinCFGuard(AsmPrinter *A) : … { … } WinCFGuard::~WinCFGuard() = default; void WinCFGuard::endFunction(const MachineFunction *MF) { … } /// Returns true if this function's address is escaped in a way that might make /// it an indirect call target. Function::hasAddressTaken gives different /// results when a function is called directly with a function prototype /// mismatch, which requires a cast. static bool isPossibleIndirectCallTarget(const Function *F) { … } MCSymbol *WinCFGuard::lookupImpSymbol(const MCSymbol *Sym) { … } void WinCFGuard::endModule() { … }