llvm.org GIT mirror llvm / db9af3f
Emit Function IDs table for Control Flow Guard Adds option /guard:cf to clang-cl and -cfguard to cc1 to emit function IDs of functions that have their address taken into a section named .gfids$y for compatibility with Microsoft's Control Flow Guard feature. Differential Revision: https://reviews.llvm.org/D40531 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322005 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian McCarthy 1 year, 10 months ago
14 changed file(s) with 336 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
195195 MCSection *PDataSection;
196196 MCSection *XDataSection;
197197 MCSection *SXDataSection;
198 MCSection *GFIDsSection;
198199
199200 public:
200201 void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
348349 MCSection *getPDataSection() const { return PDataSection; }
349350 MCSection *getXDataSection() const { return XDataSection; }
350351 MCSection *getSXDataSection() const { return SXDataSection; }
352 MCSection *getGFIDsSection() const { return GFIDsSection; }
351353
352354 MCSection *getEHFrameSection() {
353355 return EHFrameSection;
497497 virtual void EndCOFFSymbolDef();
498498
499499 virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
500
501 /// \brief Emits the symbol table index of a Symbol into the current section.
502 virtual void EmitCOFFSymbolIndex(MCSymbol const *Symbol);
500503
501504 /// \brief Emits a COFF section index.
502505 ///
4949 void EmitCOFFSymbolType(int Type) override;
5050 void EndCOFFSymbolDef() override;
5151 void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
52 void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override;
5253 void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
5354 void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
5455 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
1515 #include "CodeViewDebug.h"
1616 #include "DwarfDebug.h"
1717 #include "DwarfException.h"
18 #include "WinCFGuard.h"
1819 #include "WinException.h"
1920 #include "llvm/ADT/APFloat.h"
2021 #include "llvm/ADT/APInt.h"
129130 static const char *const DbgTimerDescription = "Debug Info Emission";
130131 static const char *const EHTimerName = "write_exception";
131132 static const char *const EHTimerDescription = "DWARF Exception Writer";
133 static const char *const CFGuardName = "Control Flow Guard";
134 static const char *const CFGuardDescription = "Control Flow Guard Tables";
132135 static const char *const CodeViewLineTablesGroupName = "linetables";
133136 static const char *const CodeViewLineTablesGroupDescription =
134137 "CodeView Line Tables";
353356 if (ES)
354357 Handlers.push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription,
355358 DWARFGroupName, DWARFGroupDescription));
359
360 if (mdconst::extract_or_null(
361 MMI->getModule()->getModuleFlag("cfguard")))
362 Handlers.push_back(HandlerInfo(new WinCFGuard(this), CFGuardName,
363 CFGuardDescription, DWARFGroupName,
364 DWARFGroupDescription));
365
356366 return false;
357367 }
358368
1919 EHStreamer.cpp
2020 ErlangGCPrinter.cpp
2121 OcamlGCPrinter.cpp
22 WinCFGuard.cpp
2223 WinException.cpp
2324 CodeViewDebug.cpp
2425
0 //===-- CodeGen/AsmPrinter/WinCFGuard.cpp - Control Flow Guard Impl ------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains support for writing Win64 exception info into asm files.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "WinCFGuard.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/CodeGen/MachineModuleInfo.h"
17 #include "llvm/CodeGen/MachineOperand.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/Metadata.h"
20 #include "llvm/MC/MCAsmInfo.h"
21 #include "llvm/MC/MCObjectFileInfo.h"
22 #include "llvm/MC/MCStreamer.h"
23
24 #include
25
26 using namespace llvm;
27
28 WinCFGuard::WinCFGuard(AsmPrinter *A) : AsmPrinterHandler(), Asm(A) {}
29
30 WinCFGuard::~WinCFGuard() {}
31
32 void WinCFGuard::endModule() {
33 const Module *M = Asm->MMI->getModule();
34 std::vector Functions;
35 for (const Function &F : *M)
36 if (F.hasAddressTaken())
37 Functions.push_back(&F);
38 if (Functions.empty())
39 return;
40 auto &OS = *Asm->OutStreamer;
41 OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGFIDsSection());
42 for (const Function *F : Functions)
43 OS.EmitCOFFSymbolIndex(Asm->getSymbol(F));
44 }
0 //===-- WinCFGuard.h - Windows Control Flow Guard Handling ----*- C++ -*--===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains support for writing windows exception info into asm files.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
14 #define LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
15
16 #include "AsmPrinterHandler.h"
17 #include "llvm/Support/Compiler.h"
18
19 namespace llvm {
20
21 class LLVM_LIBRARY_VISIBILITY WinCFGuard : public AsmPrinterHandler {
22 /// Target of directive emission.
23 AsmPrinter *Asm;
24
25 public:
26 WinCFGuard(AsmPrinter *A);
27 ~WinCFGuard() override;
28
29 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
30
31 /// \brief Emit the Control Flow Guard function ID table
32 void endModule() override;
33
34 /// \brief Gather pre-function debug information.
35 /// Every beginFunction(MF) call should be followed by an endFunction(MF)
36 /// call.
37 void beginFunction(const MachineFunction *MF) override {}
38
39 /// \brief Gather post-function debug information.
40 /// Please note that some AsmPrinter implementations may not call
41 /// beginFunction at all.
42 void endFunction(const MachineFunction *MF) override {}
43
44 /// \brief Process beginning of an instruction.
45 void beginInstruction(const MachineInstr *MI) override {}
46
47 /// \brief Process end of an instruction.
48 void endInstruction() override {}
49 };
50
51 } // namespace llvm
52
53 #endif
150150 void EmitCOFFSymbolType(int Type) override;
151151 void EndCOFFSymbolDef() override;
152152 void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
153 void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override;
153154 void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
154155 void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
155156 void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
652653 EmitEOL();
653654 }
654655
656 void MCAsmStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {
657 OS << "\t.symidx\t";
658 Symbol->print(OS, MAI);
659 EmitEOL();
660 }
661
655662 void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
656663 OS << "\t.secidx\t";
657664 Symbol->print(OS, MAI);
818818 SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO,
819819 SectionKind::getMetadata());
820820
821 GFIDsSection = Ctx->getCOFFSection(".gfids$y",
822 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
823 COFF::IMAGE_SCN_MEM_READ,
824 SectionKind::getMetadata());
825
821826 TLSDataSection = Ctx->getCOFFSection(
822827 ".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
823828 COFF::IMAGE_SCN_MEM_WRITE,
6464 addDirectiveHandler<&COFFAsmParser::ParseDirectiveType>(".type");
6565 addDirectiveHandler<&COFFAsmParser::ParseDirectiveEndef>(".endef");
6666 addDirectiveHandler<&COFFAsmParser::ParseDirectiveSecRel32>(".secrel32");
67 addDirectiveHandler<&COFFAsmParser::ParseDirectiveSymIdx>(".symidx");
68 addDirectiveHandler<&COFFAsmParser::ParseDirectiveSafeSEH>(".safeseh");
6769 addDirectiveHandler<&COFFAsmParser::ParseDirectiveSecIdx>(".secidx");
68 addDirectiveHandler<&COFFAsmParser::ParseDirectiveSafeSEH>(".safeseh");
6970 addDirectiveHandler<&COFFAsmParser::ParseDirectiveLinkOnce>(".linkonce");
7071
7172 // Win64 EH directives.
129130 bool ParseDirectiveSecRel32(StringRef, SMLoc);
130131 bool ParseDirectiveSecIdx(StringRef, SMLoc);
131132 bool ParseDirectiveSafeSEH(StringRef, SMLoc);
133 bool ParseDirectiveSymIdx(StringRef, SMLoc);
132134 bool parseCOMDATType(COFF::COMDATType &Type);
133135 bool ParseDirectiveLinkOnce(StringRef, SMLoc);
134136
519521 return false;
520522 }
521523
524 bool COFFAsmParser::ParseDirectiveSymIdx(StringRef, SMLoc) {
525 StringRef SymbolID;
526 if (getParser().parseIdentifier(SymbolID))
527 return TokError("expected identifier in directive");
528
529 if (getLexer().isNot(AsmToken::EndOfStatement))
530 return TokError("unexpected token in directive");
531
532 MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
533
534 Lex();
535 getStreamer().EmitCOFFSymbolIndex(Symbol);
536 return false;
537 }
538
522539 /// ::= [ identifier ]
523540 bool COFFAsmParser::parseCOMDATType(COFF::COMDATType &Type) {
524541 StringRef TypeId = getTok().getIdentifier();
803803 void MCStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
804804 }
805805
806 void MCStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {}
807
806808 void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
807809 }
808810
192192 << COFF::SCT_COMPLEX_TYPE_SHIFT);
193193 }
194194
195 void MCWinCOFFStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {
196 MCSection *Sec = getCurrentSectionOnly();
197 getAssembler().registerSection(*Sec);
198 if (Sec->getAlignment() < 4)
199 Sec->setAlignment(4);
200
201 new MCSymbolIdFragment(Symbol, getCurrentSectionOnly());
202
203 getAssembler().registerSymbol(*Symbol);
204 }
205
195206 void MCWinCOFFStreamer::EmitCOFFSectionIndex(const MCSymbol *Symbol) {
196207 visitUsedSymbol(*Symbol);
197208 MCDataFragment *DF = getOrCreateDataFragment();
0 ; RUN: llc < %s | FileCheck %s
1
2 ; CHECK: .section .gfids$y
3 ; CHECK: .symidx "?address_taken@@YAXXZ"
4 ; CHECK: .symidx "?virt_method@Derived@@UEBAHXZ"
5
6 ; ModuleID = 'cfguard.cpp'
7 source_filename = "cfguard.cpp"
8 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-pc-windows-msvc"
10
11 %struct.Derived = type { %struct.Base }
12 %struct.Base = type { i32 (...)** }
13 %rtti.CompleteObjectLocator = type { i32, i32, i32, i32, i32, i32 }
14 %rtti.TypeDescriptor13 = type { i8**, i8*, [14 x i8] }
15 %rtti.ClassHierarchyDescriptor = type { i32, i32, i32, i32 }
16 %rtti.BaseClassDescriptor = type { i32, i32, i32, i32, i32, i32, i32 }
17 %rtti.TypeDescriptor10 = type { i8**, i8*, [11 x i8] }
18
19 $"\01??0Derived@@QEAA@XZ" = comdat any
20
21 $"\01??0Base@@QEAA@XZ" = comdat any
22
23 $"\01?virt_method@Derived@@UEBAHXZ" = comdat any
24
25 $"\01??_7Derived@@6B@" = comdat largest
26
27 $"\01??_R4Derived@@6B@" = comdat any
28
29 $"\01??_R0?AUDerived@@@8" = comdat any
30
31 $"\01??_R3Derived@@8" = comdat any
32
33 $"\01??_R2Derived@@8" = comdat any
34
35 $"\01??_R1A@?0A@EA@Derived@@8" = comdat any
36
37 $"\01??_R1A@?0A@EA@Base@@8" = comdat any
38
39 $"\01??_R0?AUBase@@@8" = comdat any
40
41 $"\01??_R3Base@@8" = comdat any
42
43 $"\01??_R2Base@@8" = comdat any
44
45 $"\01??_7Base@@6B@" = comdat largest
46
47 $"\01??_R4Base@@6B@" = comdat any
48
49 @"\01?D@@3UDerived@@A" = global %struct.Derived zeroinitializer, align 8
50 @0 = private unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4Derived@@6B@" to i8*), i8* bitcast (i32 (%struct.Derived*)* @"\01?virt_method@Derived@@UEBAHXZ" to i8*)] }, comdat($"\01??_7Derived@@6B@")
51 @"\01??_R4Derived@@6B@" = linkonce_odr constant %rtti.CompleteObjectLocator { i32 1, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor13* @"\01??_R0?AUDerived@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.ClassHierarchyDescriptor* @"\01??_R3Derived@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.CompleteObjectLocator* @"\01??_R4Derived@@6B@" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
52 @"\01??_7type_info@@6B@" = external constant i8*
53 @"\01??_R0?AUDerived@@@8" = linkonce_odr global %rtti.TypeDescriptor13 { i8** @"\01??_7type_info@@6B@", i8* null, [14 x i8] c".?AUDerived@@\00" }, comdat
54 @__ImageBase = external constant i8
55 @"\01??_R3Derived@@8" = linkonce_odr constant %rtti.ClassHierarchyDescriptor { i32 0, i32 0, i32 2, i32 trunc (i64 sub nuw nsw (i64 ptrtoint ([3 x i32]* @"\01??_R2Derived@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
56 @"\01??_R2Derived@@8" = linkonce_odr constant [3 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.BaseClassDescriptor* @"\01??_R1A@?0A@EA@Derived@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.BaseClassDescriptor* @"\01??_R1A@?0A@EA@Base@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0], comdat
57 @"\01??_R1A@?0A@EA@Derived@@8" = linkonce_odr constant %rtti.BaseClassDescriptor { i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor13* @"\01??_R0?AUDerived@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 1, i32 0, i32 -1, i32 0, i32 64, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.ClassHierarchyDescriptor* @"\01??_R3Derived@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
58 @"\01??_R1A@?0A@EA@Base@@8" = linkonce_odr constant %rtti.BaseClassDescriptor { i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor10* @"\01??_R0?AUBase@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 0, i32 -1, i32 0, i32 64, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.ClassHierarchyDescriptor* @"\01??_R3Base@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
59 @"\01??_R0?AUBase@@@8" = linkonce_odr global %rtti.TypeDescriptor10 { i8** @"\01??_7type_info@@6B@", i8* null, [11 x i8] c".?AUBase@@\00" }, comdat
60 @"\01??_R3Base@@8" = linkonce_odr constant %rtti.ClassHierarchyDescriptor { i32 0, i32 0, i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint ([2 x i32]* @"\01??_R2Base@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
61 @"\01??_R2Base@@8" = linkonce_odr constant [2 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.BaseClassDescriptor* @"\01??_R1A@?0A@EA@Base@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0], comdat
62 @1 = private unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4Base@@6B@" to i8*), i8* bitcast (void ()* @_purecall to i8*)] }, comdat($"\01??_7Base@@6B@")
63 @"\01??_R4Base@@6B@" = linkonce_odr constant %rtti.CompleteObjectLocator { i32 1, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor10* @"\01??_R0?AUBase@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.ClassHierarchyDescriptor* @"\01??_R3Base@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.CompleteObjectLocator* @"\01??_R4Base@@6B@" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
64 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_cfguard.cpp, i8* null }]
65
66 @"\01??_7Derived@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @0, i32 0, i32 0, i32 1)
67 @"\01??_7Base@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @1, i32 0, i32 0, i32 1)
68
69 ; Function Attrs: noinline nounwind
70 define internal void @"\01??__ED@@YAXXZ"() #0 {
71 entry:
72 %call = call %struct.Derived* @"\01??0Derived@@QEAA@XZ"(%struct.Derived* @"\01?D@@3UDerived@@A") #2
73 ret void
74 }
75
76 ; Function Attrs: noinline nounwind optnone
77 define linkonce_odr %struct.Derived* @"\01??0Derived@@QEAA@XZ"(%struct.Derived* returned %this) unnamed_addr #1 comdat align 2 {
78 entry:
79 %this.addr = alloca %struct.Derived*, align 8
80 store %struct.Derived* %this, %struct.Derived** %this.addr, align 8
81 %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8
82 %0 = bitcast %struct.Derived* %this1 to %struct.Base*
83 %call = call %struct.Base* @"\01??0Base@@QEAA@XZ"(%struct.Base* %0) #2
84 %1 = bitcast %struct.Derived* %this1 to i32 (...)***
85 store i32 (...)** bitcast (i8** @"\01??_7Derived@@6B@" to i32 (...)**), i32 (...)*** %1, align 8
86 ret %struct.Derived* %this1
87 }
88
89 ; Function Attrs: noinline nounwind optnone
90 define void @"\01?address_taken@@YAXXZ"() #1 {
91 entry:
92 ret void
93 }
94
95 ; Function Attrs: noinline nounwind optnone
96 define void ()* @"\01?foo@@YAP6AXXZPEAUBase@@@Z"(%struct.Base* %B) #1 {
97 entry:
98 %retval = alloca void ()*, align 8
99 %B.addr = alloca %struct.Base*, align 8
100 store %struct.Base* %B, %struct.Base** %B.addr, align 8
101 %0 = load %struct.Base*, %struct.Base** %B.addr, align 8
102 %1 = bitcast %struct.Base* %0 to i32 (%struct.Base*)***
103 %vtable = load i32 (%struct.Base*)**, i32 (%struct.Base*)*** %1, align 8
104 %vfn = getelementptr inbounds i32 (%struct.Base*)*, i32 (%struct.Base*)** %vtable, i64 0
105 %2 = load i32 (%struct.Base*)*, i32 (%struct.Base*)** %vfn, align 8
106 %call = call i32 %2(%struct.Base* %0)
107 %tobool = icmp ne i32 %call, 0
108 br i1 %tobool, label %if.then, label %if.end
109
110 if.then: ; preds = %entry
111 store void ()* @"\01?address_taken@@YAXXZ", void ()** %retval, align 8
112 br label %return
113
114 if.end: ; preds = %entry
115 store void ()* null, void ()** %retval, align 8
116 br label %return
117
118 return: ; preds = %if.end, %if.then
119 %3 = load void ()*, void ()** %retval, align 8
120 ret void ()* %3
121 }
122
123 ; Function Attrs: noinline nounwind optnone
124 define linkonce_odr %struct.Base* @"\01??0Base@@QEAA@XZ"(%struct.Base* returned %this) unnamed_addr #1 comdat align 2 {
125 entry:
126 %this.addr = alloca %struct.Base*, align 8
127 store %struct.Base* %this, %struct.Base** %this.addr, align 8
128 %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8
129 %0 = bitcast %struct.Base* %this1 to i32 (...)***
130 store i32 (...)** bitcast (i8** @"\01??_7Base@@6B@" to i32 (...)**), i32 (...)*** %0, align 8
131 ret %struct.Base* %this1
132 }
133
134 ; Function Attrs: noinline nounwind optnone
135 define linkonce_odr i32 @"\01?virt_method@Derived@@UEBAHXZ"(%struct.Derived* %this) unnamed_addr #1 comdat align 2 {
136 entry:
137 %this.addr = alloca %struct.Derived*, align 8
138 store %struct.Derived* %this, %struct.Derived** %this.addr, align 8
139 %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8
140 ret i32 42
141 }
142
143 declare dllimport void @_purecall() unnamed_addr
144
145 ; Function Attrs: noinline nounwind
146 define internal void @_GLOBAL__sub_I_cfguard.cpp() #0 {
147 entry:
148 call void @"\01??__ED@@YAXXZ"()
149 ret void
150 }
151
152 attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
153 attributes #1 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
154 attributes #2 = { nounwind }
155
156 !llvm.module.flags = !{!0, !1}
157 !llvm.ident = !{!2}
158
159 !0 = !{i32 2, !"cfguard", i32 1}
160 !1 = !{i32 1, !"wchar_size", i32 2}
161 !2 = !{!"clang version 6.0.0 "}
0 // RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-objdump -s -t - | FileCheck %s
1 .text
2 foo:
3 ret
4 bar:
5 ret
6 .data
7 .symidx bar
8 .symidx foo
9
10 // CHECK: Contents of section .data:
11 // CHECK-NEXT: 0000 0[[BAR:[1-9]]]000000 0[[FOO:[1-9]]]000000
12 // CHECK: SYMBOL TABLE:
13 // CHECK: [ [[FOO]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 foo
14 // CHECK-NEXT: [ [[BAR]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 bar