diff options
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index fec1cce..2357203 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -294,9 +294,21 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section, assert(Section && "Cannot switch to a null section!"); getContext().clearDwarfLocSeen(); - bool Created = getAssembler().registerSection(*Section); - Section->switchSubsection(Subsection); - return Created; + auto &Subsections = Section->Subsections; + size_t I = 0, E = Subsections.size(); + while (I != E && Subsections[I].first < Subsection) + ++I; + // If the subsection number is not in the sorted Subsections list, create a + // new fragment list. + if (I == E || Subsections[I].first != Subsection) { + auto *F = getContext().allocFragment<MCDataFragment>(); + F->setParent(Section); + Subsections.insert(Subsections.begin() + I, + {Subsection, MCSection::FragList{F, F}}); + } + Section->CurFragList = &Subsections[I].second; + + return getAssembler().registerSection(*Section); } void MCObjectStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) { |