WinCFGuard.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //===-- WinCFGuard.h - Windows Control Flow Guard Handling ----*- C++ -*--===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains support for writing the metadata for Windows Control Flow
  10. // Guard, including address-taken functions, and valid longjmp targets.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
  14. #define LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
  15. #include "llvm/CodeGen/AsmPrinterHandler.h"
  16. #include "llvm/Support/Compiler.h"
  17. #include <vector>
  18. namespace llvm {
  19. class LLVM_LIBRARY_VISIBILITY WinCFGuard : public AsmPrinterHandler {
  20. /// Target of directive emission.
  21. AsmPrinter *Asm;
  22. std::vector<const MCSymbol *> LongjmpTargets;
  23. MCSymbol *lookupImpSymbol(const MCSymbol *Sym);
  24. public:
  25. WinCFGuard(AsmPrinter *A);
  26. ~WinCFGuard() override;
  27. void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
  28. /// Emit the Control Flow Guard function ID table.
  29. void endModule() override;
  30. /// Gather pre-function debug information.
  31. /// Every beginFunction(MF) call should be followed by an endFunction(MF)
  32. /// call.
  33. void beginFunction(const MachineFunction *MF) override {}
  34. /// Gather post-function debug information.
  35. /// Please note that some AsmPrinter implementations may not call
  36. /// beginFunction at all.
  37. void endFunction(const MachineFunction *MF) override;
  38. /// Process beginning of an instruction.
  39. void beginInstruction(const MachineInstr *MI) override {}
  40. /// Process end of an instruction.
  41. void endInstruction() override {}
  42. };
  43. } // namespace llvm
  44. #endif