[PATCH] D52235: [COFF] Emit @feat.00 on 64-bit and set the CFG bit when emitting guardcf tables
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 19 03:00:34 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342532: [COFF] Emit @feat.00 on 64-bit and set the CFG bit when emitting guardcf tables (authored by hans, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D52235?vs=165976&id=166081#toc
Repository:
rL LLVM
https://reviews.llvm.org/D52235
Files:
llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
llvm/trunk/test/CodeGen/WinCFGuard/cfguard.ll
Index: llvm/trunk/test/CodeGen/WinCFGuard/cfguard.ll
===================================================================
--- llvm/trunk/test/CodeGen/WinCFGuard/cfguard.ll
+++ llvm/trunk/test/CodeGen/WinCFGuard/cfguard.ll
@@ -1,5 +1,7 @@
; RUN: llc < %s | FileCheck %s
+; CHECK: .set @feat.00, 2048
+
; CHECK: .section .gfids$y
; CHECK: .symidx "?address_taken@@YAXXZ"
; CHECK: .symidx "?virt_method at Derived@@UEBAHXZ"
Index: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
@@ -587,21 +587,28 @@
if (TT.isOSBinFormatCOFF()) {
// Emit an absolute @feat.00 symbol. This appears to be some kind of
// compiler features bitfield read by link.exe.
+ MCSymbol *S = MMI->getContext().getOrCreateSymbol(StringRef("@feat.00"));
+ OutStreamer->BeginCOFFSymbolDef(S);
+ OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
+ OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
+ OutStreamer->EndCOFFSymbolDef();
+ int64_t Feat00Flags = 0;
+
if (TT.getArch() == Triple::x86) {
- MCSymbol *S = MMI->getContext().getOrCreateSymbol(StringRef("@feat.00"));
- OutStreamer->BeginCOFFSymbolDef(S);
- OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
- OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
- OutStreamer->EndCOFFSymbolDef();
// According to the PE-COFF spec, the LSB of this value marks the object
// for "registered SEH". This means that all SEH handler entry points
// must be registered in .sxdata. Use of any unregistered handlers will
// cause the process to terminate immediately. LLVM does not know how to
// register any SEH handlers, so its object files should be safe.
- OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
- OutStreamer->EmitAssignment(
- S, MCConstantExpr::create(int64_t(1), MMI->getContext()));
+ Feat00Flags |= 1;
}
+
+ if (M.getModuleFlag("cfguardtable"))
+ Feat00Flags |= 0x800; // Object is CFG-aware.
+
+ OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
+ OutStreamer->EmitAssignment(
+ S, MCConstantExpr::create(Feat00Flags, MMI->getContext()));
}
OutStreamer->EmitSyntaxDirective();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52235.166081.patch
Type: text/x-patch
Size: 2393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180919/a23c3eec/attachment.bin>
More information about the llvm-commits
mailing list