@@ -340,31 +340,33 @@ void MCObjectStreamer::emitInstToData(const MCInst &Inst,
340
340
MCFragment *F = getCurrentFragment ();
341
341
342
342
// Append the instruction to the data fragment.
343
- size_t FixupStartIndex = F->getFixups ().size ();
344
343
size_t CodeOffset = F->getContents ().size ();
345
344
SmallVector<MCFixup, 1 > Fixups;
346
345
getAssembler ().getEmitter ().encodeInstruction (
347
346
Inst, F->getContentsForAppending (), Fixups, STI);
348
347
F->doneAppending ();
349
- if (!Fixups.empty ())
350
- F->appendFixups (Fixups);
351
348
F->setHasInstructions (STI);
352
349
350
+ if (Fixups.empty ())
351
+ return ;
353
352
bool MarkedLinkerRelaxable = false ;
354
- for (auto &Fixup : MutableArrayRef (F-> getFixups ()). slice (FixupStartIndex) ) {
353
+ for (auto &Fixup : Fixups ) {
355
354
Fixup.setOffset (Fixup.getOffset () + CodeOffset);
356
- if (!Fixup.isLinkerRelaxable ())
355
+ if (!Fixup.isLinkerRelaxable () || MarkedLinkerRelaxable )
357
356
continue ;
358
- F->setLinkerRelaxable ();
357
+ MarkedLinkerRelaxable = true ;
358
+ // Set the fragment's order within the subsection for use by
359
+ // MCAssembler::relaxAlign.
360
+ auto *Sec = F->getParent ();
361
+ if (!Sec->isLinkerRelaxable ())
362
+ Sec->setLinkerRelaxable ();
359
363
// Do not add data after a linker-relaxable instruction. The difference
360
364
// between a new label and a label at or before the linker-relaxable
361
365
// instruction cannot be resolved at assemble-time.
362
- if (!MarkedLinkerRelaxable) {
363
- MarkedLinkerRelaxable = true ;
364
- getCurrentSectionOnly ()->setLinkerRelaxable ();
365
- newFragment ();
366
- }
366
+ F->setLinkerRelaxable ();
367
+ newFragment ();
367
368
}
369
+ F->appendFixups (Fixups);
368
370
}
369
371
370
372
void MCObjectStreamer::emitInstToFragment (const MCInst &Inst,
0 commit comments