xref: /freebsd/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
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 
330b57cec5SDimitry Andric   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
340b57cec5SDimitry Andric 
35480093f4SDimitry Andric   /// Emit the Control Flow Guard function ID table.
360b57cec5SDimitry Andric   void endModule() override;
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   /// Gather pre-function debug information.
390b57cec5SDimitry Andric   /// Every beginFunction(MF) call should be followed by an endFunction(MF)
400b57cec5SDimitry Andric   /// call.
410b57cec5SDimitry Andric   void beginFunction(const MachineFunction *MF) override {}
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric   /// Gather post-function debug information.
440b57cec5SDimitry Andric   /// Please note that some AsmPrinter implementations may not call
450b57cec5SDimitry Andric   /// beginFunction at all.
46480093f4SDimitry Andric   void endFunction(const MachineFunction *MF) override;
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric   /// Process beginning of an instruction.
490b57cec5SDimitry Andric   void beginInstruction(const MachineInstr *MI) override {}
500b57cec5SDimitry Andric 
510b57cec5SDimitry Andric   /// Process end of an instruction.
520b57cec5SDimitry Andric   void endInstruction() override {}
530b57cec5SDimitry Andric };
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric } // namespace llvm
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric #endif
58