@@ -151,9 +151,6 @@ class WinCOFFWriter {
151
151
bool UseOffsetLabels = false ;
152
152
153
153
public:
154
- MCSectionCOFF *AddrsigSection = nullptr ;
155
- MCSectionCOFF *CGProfileSection = nullptr ;
156
-
157
154
enum DwoMode {
158
155
AllSections,
159
156
NonDwoOnly,
@@ -1096,10 +1093,10 @@ uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
1096
1093
}
1097
1094
1098
1095
// Create the contents of the .llvm_addrsig section.
1099
- if (Mode != DwoOnly && OWriter.EmitAddrsigSection ) {
1100
- auto *Frag = Asm.getContext ().allocFragment <MCDataFragment>();
1101
- Frag-> setParent (AddrsigSection );
1102
- AddrsigSection-> addFragment (*Frag );
1096
+ if (Mode != DwoOnly && OWriter.getEmitAddrsigSection () ) {
1097
+ auto *Sec = Asm.getContext ().getCOFFSection (
1098
+ " .llvm_addrsig " , COFF::IMAGE_SCN_LNK_REMOVE );
1099
+ auto *Frag = cast<MCDataFragment>(Sec-> curFragList ()-> Head );
1103
1100
raw_svector_ostream OS (Frag->getContents ());
1104
1101
for (const MCSymbol *S : OWriter.AddrsigSyms ) {
1105
1102
if (!S->isRegistered ())
@@ -1118,10 +1115,10 @@ uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
1118
1115
}
1119
1116
1120
1117
// Create the contents of the .llvm.call-graph-profile section.
1121
- if (Mode != DwoOnly && CGProfileSection ) {
1122
- auto *Frag = Asm.getContext ().allocFragment <MCDataFragment>();
1123
- Frag-> setParent (CGProfileSection );
1124
- CGProfileSection-> addFragment (*Frag );
1118
+ if (Mode != DwoOnly && !Asm. CGProfile . empty () ) {
1119
+ auto *Sec = Asm.getContext ().getCOFFSection (
1120
+ " .llvm.call-graph-profile " , COFF::IMAGE_SCN_LNK_REMOVE );
1121
+ auto *Frag = cast<MCDataFragment>(Sec-> curFragList ()-> Head );
1125
1122
raw_svector_ostream OS (Frag->getContents ());
1126
1123
for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile ) {
1127
1124
uint32_t FromIndex = CGPE.From ->getSymbol ().getIndex ();
@@ -1209,18 +1206,6 @@ bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1209
1206
1210
1207
void WinCOFFObjectWriter::executePostLayoutBinding (MCAssembler &Asm,
1211
1208
const MCAsmLayout &Layout) {
1212
- if (EmitAddrsigSection) {
1213
- ObjWriter->AddrsigSection = Asm.getContext ().getCOFFSection (
1214
- " .llvm_addrsig" , COFF::IMAGE_SCN_LNK_REMOVE);
1215
- Asm.registerSection (*ObjWriter->AddrsigSection );
1216
- }
1217
-
1218
- if (!Asm.CGProfile .empty ()) {
1219
- ObjWriter->CGProfileSection = Asm.getContext ().getCOFFSection (
1220
- " .llvm.call-graph-profile" , COFF::IMAGE_SCN_LNK_REMOVE);
1221
- Asm.registerSection (*ObjWriter->CGProfileSection );
1222
- }
1223
-
1224
1209
ObjWriter->executePostLayoutBinding (Asm, Layout);
1225
1210
if (DwoWriter)
1226
1211
DwoWriter->executePostLayoutBinding (Asm, Layout);
0 commit comments