xref: /freebsd/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===-- WinCFGuard.h - Windows Control Flow Guard Handling ----*- C++ -*--===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
9480093f4SDimitry Andric // This file contains support for writing the metadata for Windows Control Flow
10480093f4SDimitry Andric // Guard, including address-taken functions, and valid longjmp targets.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
150b57cec5SDimitry Andric #define LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "llvm/CodeGen/AsmPrinterHandler.h"
180b57cec5SDimitry Andric #include "llvm/Support/Compiler.h"
19480093f4SDimitry Andric #include <vector>
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric namespace llvm {
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY WinCFGuard : public AsmPrinterHandler {
240b57cec5SDimitry Andric   /// Target of directive emission.
250b57cec5SDimitry Andric   AsmPrinter *Asm;
26480093f4SDimitry Andric   std::vector<const MCSymbol *> LongjmpTargets;
27*e8d8bef9SDimitry Andric   MCSymbol *lookupImpSymbol(const MCSymbol *Sym);
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric public:
300b57cec5SDimitry Andric   WinCFGuard(AsmPrinter *A);
310b57cec5SDimitry Andric   ~WinCFGuard() override;
320b57cec5SDimitry Andric 
33480093f4SDimitry Andric   /// Emit the Control Flow Guard function ID table.
340b57cec5SDimitry Andric   void endModule() override;
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric   /// Gather pre-function debug information.
370b57cec5SDimitry Andric   /// Every beginFunction(MF) call should be followed by an endFunction(MF)
380b57cec5SDimitry Andric   /// call.
beginFunction(const MachineFunction * MF)390b57cec5SDimitry Andric   void beginFunction(const MachineFunction *MF) override {}
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric   /// Gather post-function debug information.
420b57cec5SDimitry Andric   /// Please note that some AsmPrinter implementations may not call
430b57cec5SDimitry Andric   /// beginFunction at all.
44480093f4SDimitry Andric   void endFunction(const MachineFunction *MF) override;
450b57cec5SDimitry Andric };
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric } // namespace llvm
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric #endif
50