aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp')
-rw-r--r--contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp b/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
index 1e3f33e707..1486c9e868 100644
--- a/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
+++ b/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
//
// This file contains support for writing the metadata for Windows Control Flow
-// Guard, including address-taken functions and valid longjmp targets.
+// Guard, including address-taken functions and valid longjmp targets.
//
//===----------------------------------------------------------------------===//
@@ -17,7 +17,7 @@
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/IR/Constants.h"
-#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Instructions.h"
#include "llvm/IR/Metadata.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCObjectFileInfo.h"
@@ -38,7 +38,7 @@ void WinCFGuard::endFunction(const MachineFunction *MF) {
return;
// Copy the function's longjmp targets to a module-level list.
- llvm::append_range(LongjmpTargets, MF->getLongjmpTargets());
+ llvm::append_range(LongjmpTargets, MF->getLongjmpTargets());
}
/// Returns true if this function's address is escaped in a way that might make
@@ -77,50 +77,50 @@ static bool isPossibleIndirectCallTarget(const Function *F) {
return false;
}
-MCSymbol *WinCFGuard::lookupImpSymbol(const MCSymbol *Sym) {
- if (Sym->getName().startswith("__imp_"))
- return nullptr;
- return Asm->OutContext.lookupSymbol(Twine("__imp_") + Sym->getName());
-}
-
+MCSymbol *WinCFGuard::lookupImpSymbol(const MCSymbol *Sym) {
+ if (Sym->getName().startswith("__imp_"))
+ return nullptr;
+ return Asm->OutContext.lookupSymbol(Twine("__imp_") + Sym->getName());
+}
+
void WinCFGuard::endModule() {
const Module *M = Asm->MMI->getModule();
- std::vector<const MCSymbol *> GFIDsEntries;
- std::vector<const MCSymbol *> GIATsEntries;
- for (const Function &F : *M) {
- if (isPossibleIndirectCallTarget(&F)) {
- // If F is a dllimport and has an "__imp_" symbol already defined, add the
- // "__imp_" symbol to the .giats section.
- if (F.hasDLLImportStorageClass()) {
- if (MCSymbol *impSym = lookupImpSymbol(Asm->getSymbol(&F))) {
- GIATsEntries.push_back(impSym);
- }
- }
- // Add the function's symbol to the .gfids section.
- // Note: For dllimport functions, MSVC sometimes does not add this symbol
- // to the .gfids section, but only adds the corresponding "__imp_" symbol
- // to the .giats section. Here we always add the symbol to the .gfids
- // section, since this does not introduce security risks.
- GFIDsEntries.push_back(Asm->getSymbol(&F));
- }
- }
-
- if (GFIDsEntries.empty() && GIATsEntries.empty() && LongjmpTargets.empty())
+ std::vector<const MCSymbol *> GFIDsEntries;
+ std::vector<const MCSymbol *> GIATsEntries;
+ for (const Function &F : *M) {
+ if (isPossibleIndirectCallTarget(&F)) {
+ // If F is a dllimport and has an "__imp_" symbol already defined, add the
+ // "__imp_" symbol to the .giats section.
+ if (F.hasDLLImportStorageClass()) {
+ if (MCSymbol *impSym = lookupImpSymbol(Asm->getSymbol(&F))) {
+ GIATsEntries.push_back(impSym);
+ }
+ }
+ // Add the function's symbol to the .gfids section.
+ // Note: For dllimport functions, MSVC sometimes does not add this symbol
+ // to the .gfids section, but only adds the corresponding "__imp_" symbol
+ // to the .giats section. Here we always add the symbol to the .gfids
+ // section, since this does not introduce security risks.
+ GFIDsEntries.push_back(Asm->getSymbol(&F));
+ }
+ }
+
+ if (GFIDsEntries.empty() && GIATsEntries.empty() && LongjmpTargets.empty())
return;
-
- // Emit the symbol index of each GFIDs entry to form the .gfids section.
+
+ // Emit the symbol index of each GFIDs entry to form the .gfids section.
auto &OS = *Asm->OutStreamer;
OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGFIDsSection());
- for (const MCSymbol *S : GFIDsEntries)
- OS.EmitCOFFSymbolIndex(S);
-
- // Emit the symbol index of each GIATs entry to form the .giats section.
- OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGIATsSection());
- for (const MCSymbol *S : GIATsEntries) {
- OS.EmitCOFFSymbolIndex(S);
- }
+ for (const MCSymbol *S : GFIDsEntries)
+ OS.EmitCOFFSymbolIndex(S);
- // Emit the symbol index of each longjmp target to form the .gljmp section.
+ // Emit the symbol index of each GIATs entry to form the .giats section.
+ OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGIATsSection());
+ for (const MCSymbol *S : GIATsEntries) {
+ OS.EmitCOFFSymbolIndex(S);
+ }
+
+ // Emit the symbol index of each longjmp target to form the .gljmp section.
OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGLJMPSection());
for (const MCSymbol *S : LongjmpTargets) {
OS.EmitCOFFSymbolIndex(S);