LLVM
8.0.1
lib
CodeGen
AsmPrinter
WinCFGuard.cpp
Go to the documentation of this file.
1
//===-- CodeGen/AsmPrinter/WinCFGuard.cpp - Control Flow Guard Impl ------===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file contains support for writing Win64 exception info into asm files.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
WinCFGuard.h
"
15
#include "
llvm/CodeGen/AsmPrinter.h
"
16
#include "
llvm/CodeGen/MachineFunction.h
"
17
#include "
llvm/CodeGen/MachineModuleInfo.h
"
18
#include "
llvm/CodeGen/MachineOperand.h
"
19
#include "
llvm/IR/Constants.h
"
20
#include "
llvm/IR/Metadata.h
"
21
#include "
llvm/MC/MCAsmInfo.h
"
22
#include "
llvm/MC/MCObjectFileInfo.h
"
23
#include "
llvm/MC/MCStreamer.h
"
24
25
#include <vector>
26
27
using namespace
llvm
;
28
29
WinCFGuard::WinCFGuard
(
AsmPrinter
*A) :
AsmPrinterHandler
(),
Asm
(A) {}
30
31
WinCFGuard::~WinCFGuard
() {}
32
33
void
WinCFGuard::endModule
() {
34
const
Module
*M = Asm->
MMI
->
getModule
();
35
std::vector<const Function *> Functions;
36
for
(
const
Function
&
F
: *M)
37
if
(
F
.hasAddressTaken())
38
Functions.push_back(&
F
);
39
if
(Functions.empty())
40
return
;
41
auto
&OS = *Asm->
OutStreamer
;
42
OS.SwitchSection(Asm->
OutContext
.
getObjectFileInfo
()->
getGFIDsSection
());
43
for
(
const
Function
*
F
: Functions)
44
OS.EmitCOFFSymbolIndex(Asm->
getSymbol
(
F
));
45
}
llvm::AsmPrinter::OutStreamer
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition:
AsmPrinter.h:94
MachineOperand.h
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
llvm::Module
A Module instance is used to store all the information related to an LLVM module. ...
Definition:
Module.h:65
llvm::AsmPrinter::OutContext
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition:
AsmPrinter.h:89
llvm::AsmPrinterHandler
Collects and handles AsmPrinter objects required to build debug or EH information.
Definition:
AsmPrinterHandler.h:32
Metadata.h
This file contains the declarations for metadata subclasses.
WinCFGuard.h
MCAsmInfo.h
F
F(f)
llvm::Function
Definition:
Function.h:60
MCStreamer.h
MachineFunction.h
llvm::HexStyle::Asm
0ffh
Definition:
MCInstPrinter.h:33
llvm::WinCFGuard::endModule
void endModule() override
Emit the Control Flow Guard function ID table.
Definition:
WinCFGuard.cpp:33
AsmPrinter.h
llvm::MCObjectFileInfo::getGFIDsSection
MCSection * getGFIDsSection() const
Definition:
MCObjectFileInfo.h:378
llvm::AsmPrinter::MMI
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition:
AsmPrinter.h:100
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition:
AsmPrinter.h:79
llvm::MCContext::getObjectFileInfo
const MCObjectFileInfo * getObjectFileInfo() const
Definition:
MCContext.h:297
MCObjectFileInfo.h
llvm::AsmPrinter::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition:
AsmPrinter.cpp:430
llvm::WinCFGuard::~WinCFGuard
~WinCFGuard() override
Definition:
WinCFGuard.cpp:31
MachineModuleInfo.h
llvm::WinCFGuard::WinCFGuard
WinCFGuard(AsmPrinter *A)
Definition:
WinCFGuard.cpp:29
llvm::MachineModuleInfo::getModule
const Module * getModule() const
Definition:
MachineModuleInfo.h:158
Generated on Sun Dec 20 2020 13:54:05 for LLVM by
1.8.13